npm install,node-gyp只能在两台相同的计算机之一上生成错误 [英] npm install, node-gyp build error on only one of two identical machines

查看:172
本文介绍了npm install,node-gyp只能在两台相同的计算机之一上生成错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Ubuntu 14.04 VPS上运行npm install,但是它在安装业力方面一直失败. npm install命令是从Jenkins构建步骤执行的,但是当我以jenkins用户身份登录时,也会从命令行失败. 据我所知,Jenkins服务器通过Capistrano调用了另一个VPS(生产服务器)上的部署,据我所知,它与第一个VPS一样好.

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.

奇怪的是,在生产服务器(第二个VPS)上部署npm install后,它也会运行,并且在这里运行良好.

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

这是错误:

ws@0.5.0安装/var/lib/jenkins/workspace/bitbuilders-cms/node_modules/karma/node_modules/socket.io/node_modules/engine.io/node_modules/ws (node-gyp重建2> builderror.log) (0号出口) 被杀死

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

当我在此目录中检查builderror.log时,它说:

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

当我运行node-gyp重建时,它会提供相同的输出.

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

同样,在另一台计算机上它运行正常.

Again, on the other machine it runs fine.

它们都运行:

  • 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

到目前为止我尝试过的事情

我全局安装了node-gyp(npm install -g node-gyp)并正在运行节点0.12.3. 在安装之前,我运行了:

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

  • npm缓存清理
  • rm -rf node_modules
  • rm -rf〜/.node-gyp

在npm install出现此错误的VPS上,我无法向后运行任何gulp任务,因为它抱怨找不到特定的npm模块. 在此计算机上,npm install以用户jenkins的身份运行.

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.

在其他安装了npm的VPS上运行良好的情况下,随后的gulp任务也将正常运行. 在这台机器上,npm install是通过Capistrano以用户www-data的身份执行的.它们都使用shell/bin/bash.

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!

推荐答案

在虚拟机上通过Jenkins成功运行npm install和Karma之后,我得出的结论是,给我的VPS必须严重破坏麻烦. 我重新安装了Ubuntu 14.04,其余的都安装在VPS上,现在一切正常.

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.

我还注意到,重新安装后,我无需显式启动ssh-agent并添加我的ssh密钥(eval ssh-agent -sssh-add [key])即可开始在生产服务器上进行部署. 也许这根本没有关系,但是如果有人遇到类似问题,这可能会有所帮助.

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.

更新:此外,我发现这篇贴文也遇到了同样的问题.解决方案似乎是增加交换文件的大小.我没有尝试过,但这可能是正确的解决方案: https://www.digitalocean.com/community/questions/npm-gets-killed-no-matter-what?answer=18115

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

这篇关于npm install,node-gyp只能在两台相同的计算机之一上生成错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆