node-gyp errors on "Cannot find module" on Windows

22,461

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):

  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.

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

Share:
22,461
strugee
Author by

strugee

Updated on September 03, 2021

Comments

  • strugee
    strugee over 2 years

    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?