无法通过npm安装posix

时间:2015-11-09 22:12:51

标签: node.js

我正在打电话

npm install posix

但我收到以下错误:

[root@Node2 ~]# npm install posix
npm http GET https://registry.npmjs.org/posix
npm http 304 https://registry.npmjs.org/posix
npm http GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/nan

> posix@4.0.0 install /root/node_modules/posix
> node-gyp rebuild

make: Entering directory `/root/node_modules/posix/build'
  CXX(target) Release/obj.target/posix/src/posix.o
In file included from ../src/posix.cc:1:
../node_modules/nan/nan.h:316: error: ‘REPLACE_INVALID_UTF8’ is not a member of ‘v8::String’
make: *** [Release/obj.target/posix/src/posix.o] Error 1
make: Leaving directory `/root/node_modules/posix/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/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:820:12)
gyp ERR! System Linux 2.6.32-504.12.2.el6.x86_64
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/node_modules/posix
gyp ERR! node -v v0.10.36
gyp ERR! node-gyp -v v0.10.6
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0

库:https://www.npmjs.com/package/posix

我的服务器:Centos 6.7(x64)

Nodejs:0.10.36

如何解决此问题?

1 个答案:

答案 0 :(得分:1)

运行node-gyp后,您将获得

In file included from ../src/posix.cc:1:
../node_modules/nan/nan.h:316: error: ‘REPLACE_INVALID_UTF8’ is not a member of ‘v8::String’

表示您的node-gyp使用的是过时的标头。 使用以下命令更新node-gyp来更新npm

npm install -g npm

它可能需要sudo,因为它是全局安装。

Similar problem and solution here