“找不到模块"上的 node-gyp 错误;在 Windows 上
我正在尝试构建 Atom.当我运行 npm install
时,出现错误:
I'm trying to build Atom. When I run npm install
, I get an error:
Error: Cannot find module 'C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js'
我使用的是 Windows.我该如何解决这个问题?
I'm on Windows. How can I fix this?
Update 2020: 评论中有报告称此方法(在 2014 年确实有效)不再有效.请在删除任何内容之前备份此文件夹.
Update 2020: there are reports in the comments that this method (which definitely worked in 2014) does not work anymore. Please make a backup of this folder before deleting anything.
这意味着不知何故,node-gyp
模块已损坏、卸载或以其他方式出错.这可以通过两个简单的步骤来解决(tm):
This means that somehow, the node-gyp
module has been corrupted, uninstalled, or otherwise screwed up. This is can be fixed in two easy steps(tm):
Nuke
node-gyp
从轨道上核弹以防万一.以管理员身份打开 PowerShell,cd
到 Node 的安装目录(可能是C:\Program Files (x86)\nodejs
或C:\Program Files\nodejs
).现在cd .\node_modules\npm\node_modules
和rm -r node-gyp
.
Nuke
node-gyp
from orbit just in case of corruption or something. Open PowerShell as an administrator,cd
to the install directory of Node (probably eitherC:\Program Files (x86)\nodejs
orC:\Program Files\nodejs
). Nowcd .\node_modules\npm\node_modules
andrm -r node-gyp
.
重新安装 node-gyp
.为此,只需运行 npm install
.
Reinstall node-gyp
. To do this, just run npm install
.