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
@lehno We all understand the frustration some people are having, but as evidenced by this thread there are clearly many people working to make the Node ecosystem better for Windows. Why not keep things on a more positive note and support those who are spending a lot of time trying to make things better for other people? The Microsoft build tools situation is something that has been beaten to death many times over at this point.
Why on earth would I need several GBs of code to work with at most MB size programs (JS scripts, nodejs, python, npm modules...).
Several GB of stuff is to compile C/C++ code (using C/C++ compilers and SDKs).
Python is required for gyp (the underlying C/C++ build system technology for node-gyp).
This is not for any npm package which relies on pure JavaScript code but only those which are known as "npm packages with native or C/C++ modules".
It's Generalization vs. Specialization; keeping things in proportion makes it easier to improve science and technology!
I think the number of steps needed to setup the build environment or the size of it should not be addressed here because it's simply nothing that node-gyp can change. Please don't misunderstand the title as an invitation to rant about windows here. It just bloats this thread and leads to nothing. If you still have problems following the mentioned steps you can ask for help here. @jasonwilliams200OK you are doing a great job btw.
Registry keys often get messed up when there are multiple versions, or some incomplete versions installed. In such cases using VS native tools command prompt usually works since it sets correct environment variables using C:\Program Files (x86)\Microsoft Visual Studio <version>\VC\vcvarsall.bat
Would it be possible for node-gyp to call this files before starting gyp?
In cases when this file can not be found, error report from node-gyp about not being able to find sdk at the expected path, would be much easier to understand and resolve than "C:\Microsoft.Cpp.Default.props" not found errors from the compiler.
@nightwing, I agree with you, generally this is how it is. However, in this case vcvarsall.bat is throwing error from a more internal script (VC\bin\vcvars32.bat) which tries to deduce to version from the very registry key. The line of code which is setting registry in the aforementioned steps are exactly fixing that for Build Tools 2015 and that is exactly what it looks like when we install full VS.
Also note that gyp calls vcvarsall.bat for us, so we don't have to call it explicitly or use Visual Studio Command Prompt.
This is a build tools bug in Technical Preview stage. We can expect it to fix by RTM (which I think might be aligned with VS2015 Update 1 release on 30th Nov. 2015).
Thank you, @mousetraps - your comment helped, node-gyp works now on Windows 7-x64. Before installing VC++ Build Tools Technical Preview Additionally, I had to install MS Visual Studio 2015 Express with custom installation Windows 8.1 SDK checked, but I don't know, if this is necessary for others. Also I had to manually install the latest npm version:
npm install -g npm
npm cache clean
And I had to globally install the latest version of node-gyp:
npm install node-gyp@latest -g
Now I have this working environment without any node-gyp errors, if i do npm install:
Windows 7-x64
node 4.2.2-x64
python 2.7.10-x64
npm 3.4.1
node-gyp 3.1.0
If you have trouble with this messages: “warning MSB8003: Could not find WindowsSDKDir variable from the registry.TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.”
The problem may occurs even if you had installed windows sdk, or Visual C++ Build Tools 2015 (Pre-release) has been installed. I had spend almost 3 days. :(
Here comes the resolution:
- npm config set loglevel=verbose
- npm install xxx my package was time. And I found this: "…… gyp info spawn args [ 'D:\server\nodejs\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'msvs', gyp info spawn args '-G', gyp info spawn args 'msvs_version=2015', gyp info spawn args '-I', gyp info spawn args 'E:\code\github\Countly\countly\node_modules\time\build\config.gypi', gyp info spawn args '-I', gyp info spawn args 'D:\server\nodejs\node_modules\npm\node_modules\node-gyp\addon.gypi', ……"
- Edit D:\server\nodejs\node_modules\npm\node_modules\node-gyp\addon.gypi The file is the *.vcxproj data template. And I add the include path of windows sdk as below: You can solved the missing header problem as the same.
{ 'target_defaults': { 'type': 'loadable_module', 'win_delay_load_hook': 'true', 'product_prefix': '',
'include_dirs': [
'<(node_root_dir)/include/node',
'<(node_root_dir)/src',
'<(node_root_dir)/deps/uv/include',
'<(node_root_dir)/deps/v8/include',
'C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/um',
'C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/shared',
'C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt',
'C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/winrt'
],
…… The warning message still there. But all the windows headers need by the package you are building will be found.
@mousetraps
@jianglinchun, this is due to the fact that in Windows 10, the SDK location has been changed and the upstream gyp (http://code.google.com/p/gyp/) has yet to address this.
Therefore, the current (bit non-hacky) recommendation is to select both Windows 8.1 and Windows 10 SDKs when installing Build Tools 2015. This way the software perhaps actually builds against Windows 8.1 SDK on Windows 10.
See the related Universal CRT announcement here: http://blogs.msdn.com/b/vcblog/archive/2015/03/03/introducing-the-universal-crt.aspx.
Thank you @jasonwilliams200OK. I do believe this problem will be solved. :) If gentlyRm have an option not to nuking the package will help a lot. :)
So I'm thinking we should just update the README Installation instructions with @mousetraps' instructions in https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245, and then we can close this issue.
@TooTallNate @TheAlphaNerd yep, it's coming... got caught up with other things this week was just a little too optimistic on my timeline for sending out a PR. :-/
@mousetraps What about iso-image with build tools?
@Sogl we're looking into ISOs for the RTM release. As far as I understand, there's no technical / strategic / legal reason we didn't release one... it's mostly that things have been pretty hectic around here gearing up for VSConnect and Update 1, and there were more critical things to focus on at that point in time.
Additionally, I had to install MS Visual Studio 2015 Express with Windows 8 SDK checked
@stevenpietzsch - interesting... did you try selecting the windows 8.1 SDK in the build tools installer?
@jianglinchun, this is due to the fact that in Windows 10, the SDK location has been changed and the upstream gyp (http://code.google.com/p/gyp/) has yet to address this.
Therefore, the current (bit non-hacky) recommendation is to select both Windows 8.1 and Windows 10 SDKs when installing Build Tools 2015. This way the software perhaps actually builds against Windows 8.1 SDK on Windows 10.
@jasonwilliams200OK - is there an issue open in gyp on this (can't find one)? Also a more minimal recommendation would be to select Windows 8.1 SDK on Windows 10, right? (which I thought was the default in the c++ build tools anyways, which is why I didn't mention it in the original instructions, but maybe I was mistaken)
EDIT: Ahh, never mind... it appears that both are required for now... I didn't realize that the default install was actually different from the default options selected when you run through the installer.
Just as a humorous aside for anyone following this thread, if, like me you were curious about what node-gyp is, then without the least irony you will find it described here: https://github.com/nodejs/node-gyp like this:
node-gyp is a cross-platform command-line tool ..............takes away the pain of dealing with the various differences in build platforms.
Ahh... so painless...
Question for everyone who's configuration using the C++ Build Tools failed and they had to install Windows SDKs separately and whatnot...
How many of you chose to do the custom install? Was there anyone who ran into an issue after selecting the default install?
I've been trying to investigate some of these edge cases that people who were running into issues w/ the build SKU ran into so that I can update the instructions appropriately, and my hunch is that the custom install is where all of the issues are arising. The interesting thing about the build sku is that the default install does not do a full install. Rather, it installs a minimal set of dependencies from the Windows 8.1 and Windows 10 SDKs, and I've successfully been able to make things work using the default install of the Build Tools on Windows 7, Windows 8.1, and Windows 10.
@mousetraps, I always selected custom install. Will try with default installation option later. About the registry hack, is it also not required with default installation (or will it be fixed in RTM)?
@dukedougal You mean writing an impossible program? Building an impossible shape? Building a contradiction of the laws of the universe? You mean, this sentence is false? :stuck_out_tongue_winking_eye:
(Thankfully, I normally use Linux, but I feel your pain - try learning anything .NET with a vested interest and find out the primary package manager, NuGet, is only just now considering porting to your OS.)
@mousetraps my own recent failed attempts were using the custom installation as well, having selected both the Windows 10 and Windows 8.1 SDKs.
- Windows 10 x64
- Node 4.2.2
- NPM 3.5.0
- Various components and SDKs from VS 2013 and 2015 may be polluting my environment.
Curiously, running the C++ Build Tools installer again and selecting the "modify" action always displays the Windows 8.1 SDK as unselected. At this point the installer does not permit me to continue with the modification unless I check the Windows 8.1 SDK and/or uncheck the Windows 10 SDK. Checking the Windows 8.1 SDK indicates an additional 112 MB will be used, and in proceeding with the action the installer completes the "modification" in under a minute - however running the installer and choosing "modify" once again brings me back to where I started; the 8.1 SDK unchecked, and checking it apparently being interpreted as a modification to my Build Tools installation. This may simply be a misleading UI quirk or a conflict in my environment...
I will try again tomorrow with the default installation. Failing that, I will try again after removing extraneous VS components.