我已经进入 NodeJS 1 小时,所以请耐心等待。我的项目需要的包之一是 JSDom。在浏览了大部分 Internet 之后,我发现 JSDOm 有一个称为 contextify 的依赖项,它在 JSDom 安装本身中以某种方式进行了处理。所以这就是我要做的:
sudo npm install jsdom
一切都很好,直到我得到以下信息:
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
难倒!!!
我发现要在 Ubuntu 上运行 contextify,我必须有 make、python 和 G++。我都有。那么我到底错过了什么?
仅供参考,JSDOM 安装尝试之前的命令是:
mkdir ~/.node-gyp
chmod -R 777 ~/.node-gyp
我也尝试了以下方法:
npm install -g node-gyp
npm install contextify
在第二个命令中,我遇到了同样的问题。