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'
I'm on Windows. How can I fix this?
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.
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
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
.
Reinstall node-gyp
. To do this, just run npm install
.
This is very simple to solve (i faced issue after update my node)
1 . check your node where it is install
2 . check where your node-gyp path comes from
step:1 (cmd or shell)
which node
output
/c/Program Files/nodejs/node
Tips: after i update my node-gyp path is changed ,now easy to track we already got path
C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node_gyp.js
now we are going to set right path
step:2
npm config list
now you can see node-gyp path
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.12.0 node/v12.9.0 win32 ia32"
; userconfig C:\Users\balaji\.npmrc
init-author-name = "Balaji"
init-license = "MIT"
msvs_version = "2017"
node_gyp = "C:\\Users\\balaji\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js"
python = "C:\\Users\\balaji\\.windows-build-tools\\python27/python.exe"
; globalconfig C:\Users\balaji\AppData\Roaming\npm\etc\npmrc
; builtin config undefined
prefix = "C:\\Users\\balaji\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files (x86)\nodejs\node.exe
; cwd = G:\all clients project\2020\anware
; HOME = C:\Users\balaji
; "npm config ls -l" to show all defaults.
Now time to change right path, Must Run in power shell
npm config set node_gyp /path/to/executable/node_gyp
Tips if all configuration right simply delete node_modules folder then run npm install in your node path