User Tools

Site Tools


Launch of



Before using this script you MUST have cross-compiled the node.js platform on your host machine as described here.

Build your own Node.js package with the linino toolchain

Since you don't have gcc/g++ on the Yun any npm module requiring it must be cross-compiled on your host machine. Make sure you have the same version of node and npm installed on your host machine.

We can again use a build script. Create in your working directory (i.e ~/CROSS_MIPS).

export BASEDIR=$(pwd)
export STAGING_DIR=${BASEDIR}/linino_distro/staging_dir
export V8SOURCE=${BASEDIR}/v8m-rb
export PREFIX=${STAGING_DIR}/toolchain-mips_r2_gcc-4.6-linaro_uClibc-
export LIBPATH=${STAGING_DIR}/toolchain-mips_r2_gcc-4.6-linaro_uClibc-
# MIPS cross-compile exports
export CC=${PREFIX}gcc
export CXX=${PREFIX}g++
export AR=${PREFIX}ar
export RANLIB=${PREFIX}ranlib
export LINK=${PREFIX}g++
export CPP="${PREFIX}gcc -E"
export STRIP=${PREFIX}strip
export OBJCOPY=${PREFIX}objcopy
export LD=${PREFIX}g++
export OBJDUMP=${PREFIX}objdump
export NM=${PREFIX}nm
export AS=${PREFIX}as
export PS1="[${PREFIX}] \w$ "
export LDFLAGS='-Wl,-rpath-link '${LIBPATH}
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
if [ ! -d $(pwd)/mips_modules_"$2" ]
        mkdir $(pwd)/mips_modules_"$2"
cd mips_modules_"$2"/
version=`npm view "$1" version`
npm install --target_arch=mips "$1"
if [ $? -eq 1 ]
    echo " "
    echo "Build of package for MIPS failed ! ! !"
    echo " "
    exit 0
    echo ""
    echo "Making archive of "$1" for MIPS........"
    echo ""
    cd node_modules/
    tar -cvf "$1"-"$version"_mips-"$2"-ubuntu.tar.gz "$1"/ > /dev/null
    mv "$1"-"$version"_mips-"$2"-ubuntu.tar.gz ../
    rm -rf *
    echo " "
    echo ""Build of package for MIPS finished ! ! !""
    echo " "

Now make it executable with

chmod +x 

and invoke it with the name of the module you need to build i.e. :

./ serialport 24

Inside the mips_modules_24/node_modules' folder, you will find the cross-compiled module and all its dependencies. Just move over everything via scp and you should be set. In addition to this, you can define your own path(s) for the Node.js modules. Just edit the .profile file in your root home folder and set the NODE_PATH'' enviroment variable :

export NODE_PATH=path_1:path_2:.........:path_n:$NODE_PATH

then update your setup with :

root@Arduino:~# . .profile

or simply reboot the system.

PS : The whole process has successfully been tested on Node.js until v0.10.28 so far.

/var/www/ · Last modified: 2014/06/26 05:44 by arturo

2014 © dog hunter llc and the Linino Community. is a dog hunter sponsored community project. Credits