“找不到模块"上的 node-gyp 错误;在 Windows 上 [英] node-gyp errors on "Cannot find module" on Windows

查看:190
本文介绍了“找不到模块"上的 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):

  1. Nuke node-gyp 从轨道上核弹以防万一.以管理员身份打开 PowerShell,cd 到 Node 的安装目录(可能是 C:\Program Files (x86)\nodejsC:\Program Files\nodejs).现在 cd .\node_modules\npm\node_modulesrm -r node-gyp.

  1. 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 either C:\Program Files (x86)\nodejs or C:\Program Files\nodejs). Now cd .\node_modules\npm\node_modules and rm -r node-gyp.

重新安装 node-gyp.为此,只需运行 npm install.

Reinstall node-gyp. To do this, just run npm install.

这篇关于“找不到模块"上的 node-gyp 错误;在 Windows 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆