【问题标题】:npm install, node-gyp build error on only one of two identical machinesnpm install, node-gyp build error 仅在两台相同机器中的一台上
【发布时间】:2015-08-05 00:50:34
【问题描述】:

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

奇怪的是,npm install 也在生产服务器(第二个 VPS)上部署后运行,在这里运行正常。

这是错误:

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号出口) 被杀

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

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 rebuild 时,它会给出相同的输出。

同样,在另一台机器上它运行良好。

他们都跑:

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

到目前为止我所尝试的

我全局安装了 node-gyp (npm install -g node-gyp) 并运行 node 0.12.3。 在安装之前我跑了:

  • npm 缓存清理
  • rm -rf 节点模块
  • rm -rf ~/.node-gyp

在 npm install 出现此错误的 VPS 上,我无法运行任何 gulp 任务,因为它抱怨找不到某些 npm 模块。 在这台机器上 npm install 以用户 jenkins 运行。

在 npm install 运行良好的其他 VPS 上,后续的 gulp 任务也可以正常运行。 在这台机器上,npm install 是通过 Capistrano 作为用户 www-data 执行的。它们都使用 shell /bin/bash。

不幸的是,问题仍然存在。

这里出了什么问题? 非常感谢任何帮助!

【问题讨论】:

    标签: node.js ubuntu jenkins npm


    【解决方案1】:

    在 VM 上通过 Jenkins 成功运行 npm install 和 Karma 后,我得出的结论是 VPS 上的某些东西必须严重损坏,这给我带来了麻烦。 我在 VPS 上重新安装了 Ubuntu 14.04 和其余版本,现在一切正常。

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

    更新:作为补充,我发现这个帖子中有人遇到了同样的问题。解决方案似乎是增加交换文件的大小。我没有尝试过,但它可能是正确的解决方案:https://www.digitalocean.com/community/questions/npm-gets-killed-no-matter-what?answer=18115

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-04
      • 1970-01-01
      • 1970-01-01
      • 2015-06-20
      • 2021-01-13
      • 2016-05-19
      • 2022-06-22
      • 2021-03-13
      相关资源
      最近更新 更多