Skip to content Skip to sidebar Skip to footer

Npm Install Fails With Node-gyp

We are having problems running 'npm install' on our project. A certain file cannot be found : fatal error C1083: Cannot open include file: 'windows.h' It appears to be coming from

Solution 1:

The error messages have caused confusion for me and have not helped me in resolving the errors completely.

The README.md for node-gyp project does a better job of listing down the installation instructions for Unix, Max OS X and Windows.

In Windows systems you can either go with Option 1 or Option 2 but the main thing is that you need to install the Visual C++ Build Tools.

The following quote is from the Windows installation section:

  • On Windows:
    • Visual C++ Build Environment:
      • Option 1: Install Visual C++ Build Tools using the Default Install option.
      • Option 2: Install Visual Studio 2015 (or modify an existing installation) and select Common Tools for Visual C++ during setup. This also works with the free Community and Express for Desktop editions.
      [Windows Vista / 7 only] requires .NET Framework 4.5.1
    • Install Python 2.7 (v3.x.x is not supported), and run
      npm config set python python2.7
      (or see below for further instructions on specifying the proper Python version and path.)
    • Launch cmd,
      npm config set msvs_version 2015

If the above steps didn't work for you, please visit Microsoft's Node.js Guidelines for Windows for additional tips.

Common instructions for Python configuration:

If you have multiple Python versions installed, you can identify which Python version node-gyp uses by setting the '--python' variable:

$ node-gyp --python /path/to/python2.7

If node-gyp is called by way of npm and you have multiple versions of Python installed, then you can set npm's 'python' config key to the appropriate value:

$ npm config set python /path/to/executable/python2.7

Successfully configured my system following the above instructions.

System Info

λ ver

Microsoft Windows [Version 6.1.7601]

λ node -v
v6.2.0
λ npm -v
3.9.2

Links to relevant tools / articles:

Visual C++ Build Tools

Visual Studio 2015

.NET Framework 4.5.1

Python 2.7

Microsoft's Node.js Guidelines for Windows

Solution 2:

Try to install again with --force option:

npm install --force

If this doesn't work try to update npm globally:

npm update-g npm 

and try again with the --force option.

Solution 3:

I tried all the solutions above but none of them worked. My problem was with some files in the root directory that I had to delete:

package-lock.json and yarn.lock and yarn-error.log

after removing these files, I ran:

npm cache clean --force

then I ran the command:

npm install

and the error was gone

Solution 4:

I had nearly the same problem on Mac. I got lot's of spam error messages, but finally I recognized the issue, it was a version missmatch...

Description:

npm install failed on installing gyp (node-gyp):

npm ERR! gyp ERR! node -v v16.2.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok 
npm ERR! Build failed witherror code: 1

Answer :

downgrade npm / node to stable version!

Try:

Install 'n': npm i -g n

Downgrade npm: sudo n stable

Rerun npm install and this works!

Solution 5:

The last time I saw a similar error it was because I was using the wrong version of npm and/or node for one of my dependencies. Try upgrading these and try again.

Before trying again remove your node_modules directory.

You may need to investigate what versions of npm and node your dependencies need. You could try the latest versions of all your dependencies, node and npm.

Check what versions your colleagues are using.

What OS are you using? That can have an impact as version of CLANG maybe different.

Post a Comment for "Npm Install Fails With Node-gyp"