Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 413
strugee Avatar asked May 12 '14 22:05

strugee


People also ask

Why can't I find Python executable in node-Gyp?

gyp ERR! stackError: Can't find Python executable "python", you can setthe PYTHON env variable. This is because the project you're trying to build requires the node-gyppackage to build something natively on the platform. That package required Python 2.7 and a few other pieces too. The Solution Simple problems sometimes get simple solutions.

How to fix node-Gyp issues on Windows?

A Comprehensive Guide to Fixing Node-Gyp Issues on Windows 1. Try running npm install with the --no-optional flag.. If you’re lucky, the dependency that requires node-gyp will be... 2. Try downloading the windows-build-tools package.. According to the node-gyp documentation, this step should be ...

What is node-Gyp in NPM?

node-gyp is a tool that enables the compilation of native add-on modules for Node in multiple platforms. It has widespread use and is included as a dependency in many NPM packages. On most systems, this isn’t an issue, and installing node-gyp with the rest of your packages works as expected.

What version of python do I need for node Gyp?

You’ll have to run this command: npm config set msvs_version 2015 –global 5. Make sure you have Python 2.7 installed. Next up is to download Python 2.7. This is important–by default, you’ll install the newest version (3.x.x), but only 2.7 is compatible with node-gyp.


1 Answers

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.

like image 52
strugee Avatar answered Sep 27 '22 01:09

strugee