Node.js v0.10.29 and native addons on the BeagleBone Black

Brian Cooke edited this page Dec 17, 2015 · 5 revisions

There are issues with the version of Node.js v0.10.29 that comes preinstalled with Debian 2015-03-01 for the BeagleBone Black. It's not possible to install Node.js native add-ons or packages that depend on native add-ons. Attempting to do so will result in a compile error stating that ‘REPLACE_INVALID_UTF8’ is not a member of ‘v8::String’. For example, npm install onoff will result in the following output:

root@beaglebone:~/onoff# npm install onoff
/
> epoll@0.1.15 install /root/onoff/node_modules/onoff/node_modules/epoll
> node-gyp rebuild

make: Entering directory `/root/onoff/node_modules/onoff/node_modules/epoll/build'
  CXX(target) Release/obj.target/epoll/src/epoll.o
In file included from ../src/epoll.cc:15:0:
../node_modules/nan/nan.h:316:47: error: ‘REPLACE_INVALID_UTF8’ is not a member of ‘v8::String’
cc1plus: warning: unrecognized command line option "-Wno-unused-local-typedefs" [enabled by default]
make: *** [Release/obj.target/epoll/src/epoll.o] Error 1
make: Leaving directory `/root/onoff/node_modules/onoff/node_modules/epoll/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Linux 3.8.13-bone70
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /root/onoff/node_modules/onoff/node_modules/epoll
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
 
npm ERR! epoll@0.1.15 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the epoll@0.1.15 install script.
npm ERR! This is most likely a problem with the epoll 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 epoll
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.8.13-bone70
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "onoff"
npm ERR! cwd /root/onoff
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /root/onoff/npm-debug.log
npm ERR! not ok code 0
root@beaglebone:~/onoff# 

Three solutions to this problem are described here. ###Solution 1 Use a more recent version of Debian, for example, Debian 8.2 2015-11-12. This comes with Node.js v0.10.38 preinstalled which has the fixes required to resolve the issue. It should then be possible to perform the install.

###Solution 2 If you're using Debian 2015-03-01, execute the following command as root to install the newest versions of all installed packages:

apt-get update
apt-get upgrade

Among other things, this will install Node.js v.0.10.38 with the required fixes and it should then be possible to perform the install. ###Solution 3 The issue can be also be resolved by using the Node.js binaries provided by NodeSource. For example, the latest version of Node.js v0.10, which is currently v0.10.40, can be installed with:

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_0.10 | bash -
apt-get install -y nodejs

Attempting to install onoff with npm install onoff will now result in the following output:

root@beaglebone:~/onoff# npm install onoff
|
> epoll@0.1.15 install /root/onoff/node_modules/onoff/node_modules/epoll
> node-gyp rebuild

Usage: gyp_main.py [options ...] [build_file ...]

gyp_main.py: error: no such option: --no-parallel
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:343:16)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Linux 3.8.13-bone70
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/onoff/node_modules/onoff/node_modules/epoll
gyp ERR! node -v v0.10.40
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok 

npm ERR! epoll@0.1.15 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the epoll@0.1.15 install script.
npm ERR! This is most likely a problem with the epoll 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 epoll
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.8.13-bone70
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "onoff"
npm ERR! cwd /root/onoff
npm ERR! node -v v0.10.40
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0
root@beaglebone:~/onoff# 

The no such option: --no-parallel error is a known issue with node-gyp and can be resovled by editing /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js and removing this line:

 argv.push('--no-parallel')

onoff can now be successfully installed:

root@beaglebone:~/onoff# npm install onoff
-
> epoll@0.1.15 install /root/onoff/node_modules/onoff/node_modules/epoll
> node-gyp rebuild

make: Entering directory `/root/onoff/node_modules/onoff/node_modules/epoll/build'
  CXX(target) Release/obj.target/epoll/src/epoll.o
  SOLINK_MODULE(target) Release/obj.target/epoll.node
  SOLINK_MODULE(target) Release/obj.target/epoll.node: Finished
  COPY Release/epoll.node
make: Leaving directory `/root/onoff/node_modules/onoff/node_modules/epoll/build'
onoff@1.0.2 node_modules/onoff
└── epoll@0.1.15 (bindings@1.2.1, nan@2.0.8)
root@beaglebone:~/onoff# 
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.