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 the node-gyp module :
c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_lo ad_hook.c(13):
fatal error C1083: Cannot open include file: 'windows.h': No suc h file or directory [D:\ngs-frontend-next\node_modules\browser-sync\node_module s\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil\buil d\binding.sln]
This node-gyp seems to be a never ending source of pain for us. At first it complained that it needed python, so we installed that. Then it complained that it needed VCBuild, which we installed (using .NET 2.0 SDK), now we have this error. It's almost as if the errors are getting more and more obscure, and it feels like we are going down some wrong path.
The strange thing is, that other people in our team have zero problems running the npm-install.
The full error looks like this :
c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\src\win_delay_lo ad_hook.c(13):
fatal error C1083: Cannot open include file: 'windows.h': No suc h file or directory [D:\ngs-frontend-next\node_modules\browser-sync\node_module s\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil\buil d\binding.sln]
gyp ERR! build error gyp ERR! stack Error:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
failed with exit code: 1 stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node _modules\node-gyp\lib\build.js:270:23) gyp ERR! stack at emitTwo (events.js:87:13) gyp ERR! stack at ChildProcess.emit (events.js:172:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_proces s.js:200:12) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodej s\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" gyp ERR! cwd D:\ngs-frontend-next\node_modules\browser-sync\node_modules\socket. io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil gyp ERR! node -v v4.2.2 gyp ERR! node-gyp -v v3.0.3 gyp ERR! not ok npm WARN optional dep failed, continuing utf-8-validate@1.2.1gifsicle@3.0.3 postinstall D:\ngs-frontend-next\node_modules\gulp-imagemin\nod e_modules\imagemin\node_modules\imagemin-gifsicle\node_modules\gifsicle node lib/install.js
Out pacakge.json looks like this :
{
"name": "Fast-nunjucks",
"version": "0.0.1",
"description": "A simple boilerplate using nunjucks as a template engine",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/willianjusten/Fast-nunjucks.git"
},
"keywords": [
"nunjucks",
"node",
"gulp",
"stylus"
],
"author": "Willian Justen de Vasconcellos",
"license": "ISC",
"bugs": {
"url": "https://github.com/willianjusten/Fast-nunjucks/issues"
},
"homepage": "https://github.com/willianjusten/Fast-nunjucks",
"devDependencies": {
"autoprefixer-stylus": "^0.7.1",
"browser-sync": "^2.8.2",
"gulp": "^3.9.0",
"gulp-cache": "^0.3.0",
"gulp-concat": "^2.6.0",
"gulp-if": "^1.2.5",
"gulp-imagemin": "^2.3.0",
"gulp-minify-html": "^1.0.4",
"gulp-nunjucks-html": "^1.2.2",
"gulp-order": "^1.1.1",
"gulp-plumber": "^1.0.1",
"gulp-stylus": "^2.0.6",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.6",
"jeet": "^6.1.2",
"kouto-swiss": "^0.11.13",
"minimist": "^1.1.3",
"rupture": "^0.6.1"
},
"dependencies": {
"gulp-install": "^0.6.0"
}
}
For Windows 8 or 10:
Assuming node and npm installed already.
My node and npm version (At the time of writing this answer) :
node : 8.9.4
npm : 5.6.0
First install python 2.x
Make sure it is available on path
Install Visual Studio Installer
After installation, run it
After the installation it should work perfectly.
The last time I saw a similar error it was because I was using the wrong version of
npm
and/ornode
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
andnode
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.
Hey please try to install the windows build tools (global npm package)
This will fix your problem :-) You should be able to use your npm install command afterwards.
Try to install again with
--force option
:If this doesn't work try to update npm globally:
and try again with the
--force
option.Post my solution here in case anyone like me using Windows 10 still has the error after installing many Microsoft associated build tools.
All you need are:
I've tried Visual Studio 2015 before but it didn't work at all.
First of all, I uninstall all the Microsoft associated build tools. (If you didn't install anything to try to solve this problem before, skip this step.)
Install Visual Studio 2013.
Config npm as @Sourav said:
Run a
npm install
or the npm command which occurs this error. It works for me!BTW, this solution is from here.
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:
Common instructions for Python configuration:
Successfully configured my system following the above instructions.
System Info
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