安装NodeJS contextify包会产生错误

Par*_*lia 5 node.js npm jsdom node-gyp contextify

我进入NodeJS 1小时,所以请耐心等待.我的项目需要的一个软件包是JSDom.在激发了大部分互联网之后,我发现JSDOm有一个名为contextify的依赖项,它本身在JSDom安装中处理.所以这就是我的意思:

sudo npm install jsdom 
Run Code Online (Sandbox Code Playgroud)

一切顺利,直到我得到以下内容:

gyp WARN install got an error, rolling back install
gyp ERR! rebuild error Error: EACCES, stat '/root/.node-gyp/0.8.2'
gyp ERR! not ok
npm ERR! contextify@0.1.7 install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the contextify@0.1.7 install script.
npm ERR! This is most likely a problem with the contextify package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls contextify
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.2.0-60-generic
npm ERR! command "/opt/node/bin/node" "/opt/node/bin/npm" "install" "contextify"
npm ERR! cwd /opt/node
npm ERR! node -v v0.8.2
npm ERR! npm -v 1.1.36
npm ERR! code ELIFECYCLE
npm ERR! message contextify@0.1.7 install: `node-gyp rebuild`
npm ERR! message `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /opt/node/npm-debug.log
npm ERR! not ok code 0
Run Code Online (Sandbox Code Playgroud)

难倒!

我发现,为了在Ubuntu上运行,我必须有make,python和G ++.我拥有它们.那么我到底错过了什么呢?

仅供参考,JSDOM安装尝试之前的命令是:

mkdir ~/.node-gyp
chmod -R 777 ~/.node-gyp
Run Code Online (Sandbox Code Playgroud)

我也尝试了以下方法:

npm install -g node-gyp
npm install contextify
Run Code Online (Sandbox Code Playgroud)

在第二个命令,我遇到了同样的问题.

Kee*_*yOn 3

你可能需要做

须藤 npm install -g npm

然后重试(在我的 mac 上有效)

或看到此错误安装 contextify-node-gyp 重建失败

如果您在节点上执行了标准的 apt-get,它很可能落后于时代,并且采用最新的捆绑包版本可能会修复它