title: Cross-Compiling node.js modules on mips Big Endian
body: <p>I need some help to cross-compile the node modules on mips BIG ENDIAN architecture for my Arduino Yun.. I have followed the guide written by Fiore Basile and posted here some time ago :</p>
  
  <p><a href="http://fibasile.github.io/compiling-nodejs-for-arduino-yun.html" rel="nofollow">http://fibasile.github.io/compiling-nodejs-for-arduino-yun.html</a></p>
  
  <p>after compiling the patched V8 libraries and the 0.10.25 version of the node source tarball....it's time to build the node modules !</p>
  
  <p>So, I drew inspiration from Fiore's script and wrote my own one adding some fixes then and there....</p>
  
  <pre><code>#!/bin/bash
  
  export BASEDIR=$(pwd)
  
  # cd ${BASEDIR}/node-v0.10."$2"-mips/
  
  export STAGING_DIR=${BASEDIR}/linino_distro/staging_dir
  
  export V8SOURCE=${BASEDIR}/v8m-rb-dm-dev-mipsbe
  
  export PREFIX=${STAGING_DIR}/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-
  
  export LIBPATH=${STAGING_DIR}/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/lib/
  
  #export AR=${PREFIX}uclibc-ar
  
  export CC=${PREFIX}gcc
  export CXX=${PREFIX}g++
  export AR=${PREFIX}ar
  export RANLIB=${PREFIX}ranlib
  export LINK=${PREFIX}g++
  
  # export LDFLAGS='-fno-use-linker-plugin'
  
  #------------------------------------------
  
  # export CFLAGS='-fno-use-linker-plugin'
  
  # export CXXFLAGS='-fno-use-linker-plugin'
  
  #------------------------------------------
  
  export LDFLAGS='-Wl,-rpath-link '${LIBPATH}
  
  # export TARGET_PATH=${BASEDIR}/nodeyun/opt
  
  export GYPFLAGS="-Dv8_use_mips_abi_hardfloat=false -Dv8_can_use_fpu_instructions=false"
  
  export npm_config_arch=mips
  # path to the node source that was used to create the cross-compiled version
  export npm_config_nodedir=${BASEDIR}/node-v0.10."$2"-mips
  
  #node-gyp clean configure build --verbose --arch=mips
  
  if [ ! -d $(pwd)/mips_modules ]
  then
      mkdir $(pwd)/mips_modules
  fi
  
  cd mips_modules/
  
  npm install "$1"
  </code></pre>
  
  <p>However, something doesn't add up.....when launching the script with </p>
  
  <pre><code>$ ./build_npm_package.sh serialport 25
  </code></pre>
  
  <p>but i eventually get these errors.....</p>
  
  <pre><code>&gt; serialport@1.3.1 install /home/artynet/Downloads/CROSS_MIPS/mips_modules/node_modules/serialport
  &gt; node-gyp rebuild
  
  
  npm http GET https://registry.npmjs.org/serialport
  npm http 304 https://registry.npmjs.org/serialport
  npm http GET https://registry.npmjs.org/sf/0.1.6
  npm http GET https://registry.npmjs.org/bindings/1.1.1
  npm http GET https://registry.npmjs.org/async/0.1.18
  npm http GET https://registry.npmjs.org/optimist
  npm http GET https://registry.npmjs.org/nan
  npm http 304 https://registry.npmjs.org/bindings/1.1.1
  npm http 304 https://registry.npmjs.org/nan
  npm http 304 https://registry.npmjs.org/async/0.1.18
  npm http 304 https://registry.npmjs.org/optimist
  npm http 304 https://registry.npmjs.org/sf/0.1.6
  npm http GET https://registry.npmjs.org/wordwrap
  npm http 304 https://registry.npmjs.org/wordwrap
  Traceback (most recent call last):
    File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in &lt;module&gt;
      sys.exit(gyp.script_main())
  AttributeError: 'module' object has no attribute 'script_main'
  gyp ERR! configure error 
  gyp ERR! stack Error: `gyp` failed with exit code: 1
  gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
  gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
  gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
  gyp ERR! System Linux 3.11.0-19-generic
  gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
  gyp ERR! cwd /home/artynet/Downloads/CROSS_MIPS/mips_modules/node_modules/serialport
  gyp ERR! node -v v0.10.25
  gyp ERR! node-gyp -v v0.12.2
  gyp ERR! not ok 
  npm ERR! serialport@1.3.1 install: `node-gyp rebuild`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the serialport@1.3.1 install script.
  npm ERR! This is most likely a problem with the serialport package,
  npm ERR! not with npm itself.
  npm ERR! Tell the author that this fails on your system:
  npm ERR!     node-gyp rebuild
  npm ERR! You can get their info via:
  npm ERR!     npm owner ls serialport
  npm ERR! There is likely additional logging output above.
  
  npm ERR! System Linux 3.11.0-19-generic
  npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "serialport"
  npm ERR! cwd /home/artynet/Downloads/CROSS_MIPS/mips_modules
  npm ERR! node -v v0.10.25
  npm ERR! npm -v 1.3.24
  npm ERR! code ELIFECYCLE
  npm ERR! 
  npm ERR! Additional logging details can be found in:
  npm ERR!     /home/artynet/Downloads/CROSS_MIPS/mips_modules/npm-debug.log
  npm ERR! not ok code 0
  </code></pre>
  
  <p>By googling around the suggestions are always the same....."set the compiler to..." "export the npm_config_arch variable to mips" "export the npm_config_nodedir to...." and so on but the result is always the same....</p>
  
  <p>.....can you help to figure it out ?</p>
  
  <p>Thanks in advance, Arturo</p>