本文介绍了npm install <模块>持续错误?(节点gyp构建?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试安装 jsdom,例如:

I try to install jsdom such:

$ sudo npm install -g jsdom
# OR
$ sudo npm install    jsdom

在一些成功的命令之后,安装很快失败,第一条错误信息出现在 [....] 之后:

After some successfull command, the install quickly fails, with the first error message being after the [....] :

$ sudo npm install jsdom
npm http GET https://registry.npmjs.org/jsdom
npm http 304 https://registry.npmjs.org/jsdom
[....]

> [email protected] install /home/yug/Desktop/QGis/WikiAtlas/1_shaded_relief/test/node_modules/jsdom/node_modules/contextify
> node-gyp rebuild

gyp: /home/yug/.node-gyp/0.10.25/common.gypi not found (cwd: /home/yug/Desktop/QGis/WikiAtlas/1_shaded_relief/test/node_modules/jsdom/node_modules/contextify) while reading includes of binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16)
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.8.0-35-generic
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/yug/Desktop/QGis/WikiAtlas/1_shaded_relief/test/node_modules/jsdom/node_modules/contextify
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm http 304 https://registry.npmjs.org/domhandler
npm http 304 https://registry.npmjs.org/domelementtype
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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.8.0-35-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "jsdom"
npm ERR! cwd /home/yug/Desktop/QGis/WikiAtlas/1_shaded_relief/test
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE

npm http 304 https://registry.npmjs.org/qs
npm http 304 https://registry.npmjs.org/entities
....

提示?其他模块也会出现此错误:

Hint? This bug also appears for other modules :

 $sudo npm install -g topojson
 #bug with `[email protected] install` error as well.

如何解决这个问题?

我尝试了 sudo apt-get remove --purge nodejs npm topojson 然后通过各种方式重新安装.即使 nodejs 重新安装成功,错误仍然存​​在,所以我猜它是相当上下文的 (node.gyp ? cwd ? ...).尝试删除/重新安装的方法:

I tried sudo apt-get remove --purge nodejs npm topojson then reinstalling via various ways. Even when nodejs reinstall is successfull, the error stays, so I guess it's rather contextual (node.gyp ? cwd ? ...). Remove/reinstall ways tried :

  • ubuntu_setup.sh
    • way1:继续

    推荐答案

    似乎我找到了一种方法,通过仔细删除计算机上所有与节点相关的文件和文件夹.

    Seems I found a way by carefully deleting all node-related file and folder on my computer.

    0.上下文:我之前使用

    sudo apt-get remove --purge nodejs npm topojson
    

    接下来是 ~3 种不同的方法来重新安装 nodejs.我尝试了每一种方式,从清理到重新安装,在 2 & 之间4 次.

    followed by ~3 different ways to reinstall nodejs. I tried EACH way, from clean-up to reinstall, between 2 & 4 times.

    1.终端清理:让我们首先以尽可能最深的方式清理我的烂摊子:

    1. Terminal purging: Let's first cleaned up my mess the deepest way possible:

    npm cache clean; bower cache clean; grunt clean;
    sudo apt-get remove --purge nodejs npm topojson
    

    然而,我刚刚注意到这种深度清除不会清除/删除已安装的节点模块,它们会保持持久性.

    Yet, I just noticed that this deep purge does NOT purge/delete installed node modules, which stay persistent.

    2.手动清除:此外,我通过对 nodejsnode_modules 的手动清除进一步推动了清除.我在我的计算机上查找了 ALL 相关文件夹,越靠近根目录(ubuntu:/home//)越好.我小心地删除了所有以前安装的全局 .../node-modules/ 文件夹,而不删除本地模块(特定的本地安装,它们仍在工作).

    2. Hand purge: Also, I pushed the purge further with an hand purge for both nodejs and node_modules. I looked for ALL related folders on my computer, nearer the root (ubuntu: /home/<user>/) the better. I was careful to delete all previously installed global .../node-modules/ folders, without deleting local modules (specific local installations, which were still working).

    3.重新安装:然后以下控制台允许干净地重新安装:

    3. Reinstall: Then the following consoles allowed a clean reinstall:

    sudo apt-get update
    sudo apt-get install python-software-properties python g++ make
    sudo add-apt-repository ppa:chris-lea/node.js
    sudo apt-get update
    sudo apt-get install nodejs
    
    sudo npm install -g topojson jsdom
    

    之后,我通过 npm 模块 topojson(取决于 jsdom)的文件转换工作正常:

    Afterwhat, my file conversion via npm module topojson (depending itself on jsdom) worked fine :

    cd /myfolder/
    topojson -o output.topo.json input.geo.json
    

    4.结论:我不知道为什么,删除哪个文件/文件夹允许成功sudo apt-get install nodejs + sudo npm install -g topojson重新安装.但是这个通过鼠标和递归删除的深度清理 sudo rm -r [node related folder/file] 最终解锁了我的情况.

    4. Conclusion: I can not identify why, which file/folder deletion allowed the successful sudo apt-get install nodejs + sudo npm install -g topojson reinstall. But thist deep cleanup via mouse and recursive remove sudo rm -r [node related folder/file] definitively unlocked my situation.

    /!\非常小心rm -r 递归删除./!\

    /!\ Be very careful with the rm -r recursive remove. /!\

    这篇关于npm install <模块>持续错误?(节点gyp构建?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 03:23