Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
83 lines (64 sloc) 3.85 KB
layout title description date author index-image-url index-image-alt keywords categories
From the Snap Support Team: Common NPM issues
Here are three easy troubleshooting tips for common problems on Snap
Ankit Srivastava
tips from the Snap CI support team
snap-ci, deploy software, continuous delivery, software delivery, debugging, snap shell, sudo, continuous integration

From the Snap CI Support Desk{: .screenshot .big}

As product specialists, Snap's support team gets lots of requests from customers stuck with build failures and errors. One of the most common is an npm error. If you get an npm error for your build, it could be because of the node version, or because of open GitHub issues with npm. Sometimes builds work on your local machine, but doesn’t work on Snap.

To figure out what's gone wrong, we usually start by traversing the complete build log and look for the npm error. Once we get that, we try to replicate it on our instance and determine if there are any related open npm issues filed on GitHub. I would like share one such case (below) where the node project was failing due some dependency.

Here's the log:

node-pre-gyp ERR! node -v v4.2.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.4
node-pre-gyp ERR! not ok
Failed to execute '/opt/local/nvm/versions/node/v4.2.1/bin/node 
/var/snap-ci/repo/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js clean' (1)
npm ERR! Linux 2.6.32-042stab105.14
npm ERR! argv "/opt/local/nvm/versions/node/v4.2.1/bin/node" 
"/opt/local/nvm/versions/node/v4.2.1/bin/npm" "install"
npm ERR! node v4.2.1
npm ERR! npm  v2.14.7

npm ERR! usb@1.1.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the usb@1.1.0 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the usb package,
npm ERR! not with npm itself.

Here is the complete summary of the problem:

We tried to replicate the failure scenario by forking the project and got the same error using node 4.2.1. We did some research and found this open issue on GitHub which says that a higher version of GCC / libstdc++ is required that supports C++11.

After upgrading the GCC, we ran into another error mentioned below:

../libusb/libusb/os/linux_udev.c:40:21: fatal error: libudev.h: No such file or directory 
#include <libudev.h> ^ compilation terminated. make: *** 
[Release/] Error 1 make: Leaving directory 
`/var/snap-ci/repo/node_modules/usb/build' gyp ERR! build error gyp ERR! stack Error: `make` failed with 
exit code: 2 gyp ERR! stack at ChildProcess.onExit
(/var/snap-ci/repo/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23) gyp ERR! stack 
at emitTwo (events.js:100:13) gyp ERR! stack at ChildProcess.emit (events.js:185:7) gyp ERR! 
stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) gyp ERR! 
System Linux 2.6.32-042stab105.14

Finally, we were able to make it work with node version 5.7 and installing libudev package.

Here are the commands we used:

sudo wget -O /etc/yum.repos.d/devtools-2.repo
sudo yum install devtoolset-2-gcc-c++ -y
g++ --version
source /opt/rh/devtoolset-2/enable
g++ --version
sudo rpm -Uvh
npm install -g grunt-cli
npm install

We hope this will be helpful to you as you navigate running builds from Snap. Read more articles from our support desk.

Snap CI © 2017, ThoughtWorks

You can’t perform that action at this time.