npm install, node-gyp build error on only one of t

2019-09-10 06:39发布

I'm trying to run npm install on an Ubuntu 14.04 VPS but it keeps failing on installing karma. The command npm install is executed from a Jenkins build step but also fails from the command line when I log in as jenkins user. The Jenkins server invokes a deployment through Capistrano on another VPS (production server) which is, as far as I know, as good as identical to the first one.

Strangely, npm install is also run after deployment on the production server (the second VPS) and here it runs fine.

Here's the error:

ws@0.5.0 install /var/lib/jenkins/workspace/bitbuilders-cms/node_modules/karma/node_modules/socket.io/node_modules/engine.io/node_modules/ws (node-gyp rebuild 2> builderror.log) || (exit 0) Killed

When I check builderror.log in this directory it says:

In file included from ../src/bufferutil.cc:15:0:
../node_modules/nan/nan.h: In function 'v8::Local<v8::Signature> NanNew(v8::Handle<v8::FunctionTemplate>, int, v8::Handle<v8::FunctionTemplate>*)':
../node_modules/nan/nan.h:207:78: error: no matching function for call to 'v8::Signature::New(v8::Isolate*, v8::Handle<v8::FunctionTemplate>&, int&, v8::Handle<v8::FunctionTemplate>*&)'
 return v8::Signature::New(v8::Isolate::GetCurrent(), receiver, argc, argv);
                                                                          ^
../node_modules/nan/nan.h:207:78: note: candidate is:
In file included from ../src/bufferutil.cc:7:0:
/var/lib/jenkins/.node-gyp/2.0.2/deps/v8/include/v8.h:4188:27: note: static v8::Local<v8::Signature> v8::Signature::New(v8::Isolate*, v8::Handle<v8::FunctionTemplate>)
   static Local<Signature> New(
                       ^
/var/lib/jenkins/.node-gyp/2.0.2/deps/v8/include/v8.h:4188:27: note:       candidate expects 2 arguments, 4 provided
../src/bufferutil.cc: In static member function 'static void BufferUtil::Initialize(v8::Handle<v8::Object>)':
../src/bufferutil.cc:32:17: warning: 'v8::Local<v8::String> NanSymbol(const char*, int)' is deprecated (declared at ../node_modules/nan/nan.h:616) [-Wdeprecated-declarations]
 target->Set(NanSymbol("BufferUtil"), t->GetFunction());
             ^
../src/bufferutil.cc:32:39: warning: 'v8::Local<v8::String> NanSymbol(const char*, int)' is deprecated (declared at ../node_modules/nan/nan.h:616) [-Wdeprecated-declarations]
 target->Set(NanSymbol("BufferUtil"), t->GetFunction());
                                   ^
make: *** [Release/obj.target/bufferutil/src/bufferutil.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/var/lib/jenkins/.nvm/versions/io.js/v2.0.2/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1009:12)
gyp ERR! System Linux 3.2.0-56-generic
gyp ERR! command "/var/lib/jenkins/.nvm/versions/io.js/v2.0.2/bin/iojs" "/var/lib/jenkins/.nvm/versions/io.js/v2.0.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /var/lib/jenkins/workspace/bitbuilders-cms/node_modules/karma/node_modules/socket.io/node_modules/engine.io/node_modules/ws
gyp ERR! node -v v2.0.2
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok

When I run node-gyp rebuild it gives me the same output.

Again, on the other machine it runs fine.

They both run:

  • ubuntu 14.04
  • io.js 2.0.2
  • npm 2.9.0
  • GNU Make 3.81
  • python 2.7.6
  • gcc 4.8.2
  • node-gyp 1.0.3
  • nvm 0.25.2

What I have tried so far

I globally installed node-gyp (npm install -g node-gyp) and running node 0.12.3. Before installing I ran:

  • npm cache clean
  • rm -rf node_modules
  • rm -rf ~/.node-gyp

On the VPS where npm install gives this error I cannot run any gulp tasks aftwerwards since it complains it cannot find certain npm modules. On this machine npm install is run as user jenkins.

On the other VPS where npm install runs fine, the subsequent gulp task also runs without errors. On this machine, npm install is executed through Capistrano as user www-data. They both use shell /bin/bash.

Unfortunately the problem remains.

What is going wrong here? Any help is greatly appreciated!

1条回答
相关推荐>>
2楼-- · 2019-09-10 07:15

After successfully running npm install and Karma through Jenkins on a VM, I came to the conclusion that something had to be seriously borked on the VPS that was giving me trouble. I reinstalled Ubuntu 14.04 and the rest on the VPS and now everything runs fine.

I also noticed that after the reinstall I didn't need to explicitly start ssh-agent and add my ssh key anymore (eval ssh-agent -s and ssh-add [key]) to start deployment on the production server. Maybe this is not related at all, but if anyone runs into similar problems this might be of help.

Update: As an addition, I found this posting of someone who faced the same problem. The solution appears to be to increase the size of the swap-file. I haven't tried this but it might be the right solution: https://www.digitalocean.com/community/questions/npm-gets-killed-no-matter-what?answer=18115

查看更多
登录 后发表回答