Windows users are not happy.
It all started with this conversation.
As I said, I'm pretty much a newbie and I don't even know what node-gyp does, but what I DO know is that it's a pain to run Windows and install a project with node-gyp as a dependency. Some numbers:
It's bizarre that a nodejs developer needs to install visual studio (even the express edition) in order to be able to work on Windows. Even more bizarre is that I, as a .NET developer with full visual studio installed in my machine still can't download a bunch of projects that use this project.
With that being said, I'd like to know from all of you what should we do to make windows users fall in the pit of success? What are the alternatives? Does Microsoft can solve this in any way?
This issue is fixed (kinda)
@mousetraps pointed that Microsoft is shipping the C++ build tools separately now. Check here
Some updates on this gigantic thread
Absolutely non-official statement that @Microsoft is aware of this issue and seeing what can be done
@mousetraps said that this thread "is high on people's radar" at @Microsoft
Very good Q&A about noge-gyp issues on Windows and why they happen
@dekarguy took the time to answer some questions about what we all are going through
@am11 This is exactly the problem I am having! I spent a many hours banging my head against the wall because I could use npm and node-gyp without issue from CMD (I did a complete Visual Studio 2015 pro installation) but in PowerShell I get MSBuild errors unless I have
$env:Path = ${env:ProgramFiles(x86)} + "\MSBuild\14.0\bin;" + $env:Path
in my PowerShell profile. And it must be prepended, not appended. I spent the better part of an afternoon isolating the environment variables that were different between CMD and PS and one by one testing to see which made the difference (I wish I would have found this thread sooner!!). The thing I'm not really clear is that the PATH variable is the same in both environments (before I modify it as I mentioned above. It bugs me to no end that I can't isolate the breaking difference between the two even after examining VsDevCmd.bat' andVsMSBuildCmd` in detail. To make it even more frustrating, npm succeeds at a regular Command Prompt - it doesn't even have to be a Developer Command Prompt.
In the figure shown previously, I prepended the system environment path.
The precedence order of environment variable is process, system and then user. In your case, it seems like cmd is inheriting the msbuild from some startup/autoexec script (for the current process) which is why it is not visible in user/system PATH and the fact that in PS it was unavailable. You can always check the msbuild version with msbuild /version.
it doesn't even have to be a Developer Command Prompt
To be fairly honest, Developer Command Prompt is not the requirement when your project relies on MSBuild and it is discoverable via PATH.
Some additional CLI gotchas:
:: in cmd / bat
:: To change the current process PATH:
SET PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin\;%PATH%
:: To change the `user` PATH:
SETX PATH %ProgramFiles(x86)%\MSBuild\14.0\Bin\;%PATH%
# in PowerShell
# To change the current process PATH:
$env:PATH="${env:ProgramFiles(x86)}\MSBuild\14.0\Bin\;$env:PATH"
# To change the `user` PATH:
SETX PATH "${env:ProgramFiles(x86)}\MSBuild\14.0\Bin\;$env:PATH"
To change the system environment variable, the shell needs to be running as administrator, then: use the /m switch as in: SETX /m ....
@am11
Interesting! I will have to investigate further. It's not enough that it works, I really like to understand why it does.
I have no idea how to diagnose what is wrong.
this is what PowerShell reads after I type npm install msvs_version=2015
I've installed the build tools, then tried visual studio 2015 community edition, both at least twice. reinstalled node and python several times. I don't know anything about this stuff or how to make it work, trying to match the error codes with other errors in this thread hasn't gotten me very far.
Could someone please skim through that log and point me in the right direction? Thanks!
@benflinn, since stocks4you is not available on http://npmjs.org, so I tried to install node-inspector package instead which is the failing dependency going by your error log. It successfully installed here. My environment is:
- node v5.0
- npm v3.3.6
- VS2015 community
- Python v2.7
npm config set msvs_version 2015 --global(ran once)
I think you just need to reference some higher version of node-inspector (current version is v0.12.5) in your package.json file.
@am11 thanks for pointing that out, installed node-inspector v0.12.5 globally and it seems to be working now! :)
@mousetraps Please add to your guide that it is important to install BOTH Windows 8 SDK AND Windows 10 SDK during the Build Tools install. Or that if node-gyp prints errors that it cannot open include file [some Windows SDK header-file] that this can be fixed if you customize your Build Tools and install BOTH SDKs.
I had previously thought that the default install option with only Windows 8 SDK is sufficient, but it wasn't. This was the case for @mtpultz and @ricmed205 under Windows 10 and for me under Windows 7.
Maybe the error is that the installer is putting the required header files only in "C:\Program Files (x86)\Windows Kits\10\Include" and not in "C:\Program Files (x86)\Windows Kits\8.1\Include" even if I select only Windows 8 SDK during install which seems strange.
@hfinger, that is not the built tools error. It is gyp error that it does not locate Windows 10 SDK (which for the first time in a very long time is at a different location than its predecessors).
@jasonwilliams200OK, I disagree there, but I am no expert. Other people who are installing on a fresh VM are not having this issue. Just to repeat my steps, I first uninstalled everything associated with Visual Studio / .net Framework / Windows SDKs. Then I started fresh with the guide of @mousetraps to install Build Tools. The default install option (at least on Windows 7) is that it installs only the Windows 8.1 SDK and NOT the Windows 10 SDK. During install it puts stddef.h and winsock2.h etc in "Windows Kits\10\Include" although I only installed SDK 8.1. These files are missing in "Windows Kits\8.1\Include".
Only if I then also install Windows 10 SDK, node-gyp works. So gyp is definitely locating the Windows 10 SDK. It seems it was not locating the Windows 8.1 SDK header files, because Build Tools installed headers only in the Windows 10 SDK folder, although I only installed Windows 8.1 SDK.
@hfinger, gyp is NOT locating Windows 10 SDK. See https://github.com/nodejs/node-gyp/issues/679#issuecomment-137970103.
@jasonwilliams200OK I know that this fixes it, because I used that workaround before installing Windows 10 headers. But, it is strage that I would hard code the location of the Windows 10 SDK header files in gyp, although I DID NOT install Windows 10 SDK. I installed only WIndows 8.1 SDK.
So if you are using that workaround by modyfing common.gypi, you might instead just install the Windows 10 SDK correctly in addition to the Windows 8.1 SDK. At least for me that solved it without the need to hard code the location of the header files in gyp. So, I am quite sure that Build-Tools installer produced a weird setup on my disk, because it installs Windows 8.1 headers in the wrong folder.
@hfinger, in this case, you are the first one running into it after: https://github.com/nodejs/node-gyp/issues/629#issuecomment-159808154 (also see comments above and below that one). I have tested it thoroughly and custom install was not required on at least Windows 7 fresh installation. Maybe the package i was testing (selenuim-webdriver) wasn't using those misplaced headers.
The link was updated https://www.microsoft.com/en-us/download/details.aspx?id=49983 (now uses the updated version of compiler which comes with VS2015 Update 1). I used default install on Windows 7 without any hack and it worked.
@mousetraps I am on a fresh copy of Windows 8 and the Microsoft Build Preview tool fails to install.
EDIT: I was to install the Microsoft tool. Make sure you do a Windows update. Now I tried to do a npm install and I kept getting this.
C:\ProgramData\chocolatey\lib\Cygwin\tools\cygwin\home\William\projects\lootz\no
de_modules\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Program F
iles\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\n
ode-gyp.js" rebuild ) else (node rebuild )
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targ
ets(356,5): error MSB6006: "CL.exe" exited with code -1073741515. [C:\ProgramDa
ta\chocolatey\lib\Cygwin\tools\cygwin\home\William\projects\lootz\node_modules\
utf-8-validate\build\validation.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` fail
ed with exit code: 1
gyp ERR! 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:88:13)
gyp ERR! stack at ChildProcess.emit (events.js:173:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:201:12)
gyp ERR! System Windows_NT 6.3.9600
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 C:\ProgramData\chocolatey\lib\Cygwin\tools\cygwin\home\William\proj
ects\lootz\node_modules\utf-8-validate
gyp ERR! node -v v5.2.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: `node-gyp re
build`
npm WARN install:[email protected] Exit status 1
npm WARN EPEERINVALID [email protected] requires a peer of kerberos@~0.0 but n
one was installed.
Still having errors after installing python 2.7, VC++ Build Tools Technical Preview and setting npm config set msvs_version 2015 --global as @mousetraps suggested
Here's what I see in console:
bufferutil.cc C:\Users\Dmitry_Kabardinov\.node-gyp\4.0.0\include\node\v8.h(18): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Users\Dmitry_Kabardinov\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\node_module s\ws\node_modules\bufferutil\build\bufferutil.vcxproj]
@dKab I had the same error message. I solved it by again starting the Build Tools installer and clicking customize and then installing BOTH SDKs.
Or alternatively, by manually modyfing the include paths as suggested here: https://github.com/nodejs/node-gyp/issues/679#issuecomment-137970103
@hfinger
I solved it by again starting the Build Tools installer and clicking customize and then installing BOTH SDKs.
It worked! Thanks, man! You are the best.
I also found it was necessary to manually select the Windows 10 SDK when installing Visual C++ Build Tools 2015 as described by https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245.
- If you select
Typicalinstall, you don't have to choose both SDKs, the installer will do the right thing. - If you select
Custominstall then you have to chose BOTH SDKs.
So the better workaround at the moment is to chose Typical install.
Meanwhile, Microsoft should fix the installer to work with default SDK when user selects custom install.
If you select Typical install, you don't have to choose both SDKs, the installer will do the right thing.
@jasonwilliams200OK No, that is definitely not correct!! It might be working for you if you are installing on a fresh Windows machine, but not if you had previously old Versions of Visual Studio or some other stuff installed! I made sure to first uninstall all old Visual Studios and SDKs and then did a "Typical" install and it did not work!
@hfinger, you are mistaken dude. try again.