安装节点模块时出错

时间:2016-07-21 14:16:04

标签: node.js

我刚安装了最近的node-gyp,我正在使用node v4.4.7。

尝试安装节点模块时,我遇到了这个奇怪的错误:

> node-gyp rebuild

make: Entering directory `/node_modules/libxml-xsd/node_modules/libxmljs-mt/build'
  CXX(target) Release/obj.target/xmljs/src/libxmljs.o
make: g++: Command not found
make: *** [Release/obj.target/xmljs/src/libxmljs.o] Error 127
make: Leaving directory `/node_modules/libxmljs-mt/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.19.0-32-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /node_modules/libxml-xsd/node_modules/libxmljs-mt
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok 
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! weird error 1
npm ERR! not ok code 0

请注意,在错误中写入我正在使用节点0.10.25。 当我输入:

node -v

我明白了:

v4.4.7

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:0)

查看错误消息:

  

make:g ++:找不到命令

您的Node版本太旧并不抱怨。它抱怨它无法找到C ++编译器。您需要安装g ++才能编译模块的C ++组件。

答案 1 :(得分:0)

首先尝试通过运行以下命令来安装 build-essential

sudo apt install build-essential

如果提示已安装,请先删除 gcc g ++ build-essential ,然后安装 build-必不可少的。 为此,请运行此程序。

sudo apt remove gcc g++ build-essential && sudo apt update && sudo apt install build-essential

希望它能解决您的问题。

相关问题