【发布时间】:2023-04-01 13:56:01
【问题描述】:
我已经学习了 1 小时 NodeJS,所以请耐心等待。我的项目需要的包之一是 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
在第二个命令中,我遇到了同样的问题。
【问题讨论】:
-
您可能需要执行
sudo npm install -g npm并重试(它在我的 Mac 上有效)或查看此 stackoverflow.com/questions/21148917/…。如果你在节点上做了一个标准的 apt-get,它很可能已经落后了,采用最新的捆绑包版本可能会解决它 -
我会先升级到更新版本的 Node.js。您正在运行 0.8.2(甚至不是 0.8.x 系列中的最新版本),但 0.10.26 是最新的稳定版本。
-
@KeepCalmAndCarryOn 就是这样,我做到了,一切正常!
-
你应该发布这个作为答案,我会接受
-
我把它作为答案发布了,谢谢
标签: node.js npm jsdom node-gyp contextify