Node-gyp: [solved] Using Visual C++ Build Tools 2015 – standalone C++ tools

Created on 6 Nov 2015  Â·  76Comments  Â·  Source: nodejs/node-gyp

[EDIT]

Guide

1 Your OS MUST be Windows
2 Check that python is in your path by writting python --version in the console. If not then
2.1 Download python 2.7 (I recommend chocolatey (choco install python2 -y))

  1. Are you on Windows 7? Then follow the rest of 3.x
    3.1 Check that you have .NET 4.5.1+ installed. If not then
    3.2 Download and install .NET 4.5.1 (.NET 4.5.2 will also work just fine)
    4 Download Microsoft Visual C++ Build Tools 2015 Technical Preview
    4.1 Install the Windows 8.1 SDK if you haven't already. _Note_; I recently updated to Windows 10 and had to install the Windows 10 SDK before node-gyp would successfully build.
    5 Set the npm config variable _msvs_version_ to _2015_: npm config -g set msvs_version 2015
    6 Do npm i in what-ever project with node-gyp as a dependency without seeing weird error messages :+1:

Tested with node 5.0.0+ and npm 3.3.6

thanks to @mousetraps

I happily noticed that MS provides a standalone c++ compiler. I will try to use it with node-gyp (via utf-8-validate) and report my findings here.

http://blogs.msdn.com/b/vcblog/archive/2015/11/02/announcing-visual-c-build-tools-2015-standalone-c-tools-for-build-environments.aspx

Documentation Windows

Most helpful comment

@Almusamim you're running in to our __pfnDliNotifyHook2 problem which has been covered pretty extensively on this issue tracker (not that I'm suggesting it's easy to identify!). In order to use the latest release of Visual Studio 2015 you need to get the latest version of node-gyp which comes with the latest v2 and v3 releases of npm. You should be able to run npm i npm@latest -g to get the latest version. Our next v6 release of Node.js should come with this too.

All 76 comments

Adding C:\Program Files (x86)\MSBuild\14.0\Bin to my PATH yields no result. Still getting:

MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location o f the component to the system path if it is installed elsewhere.  [C:\Users\dotnet\Projects\firefund-cli\node_modules\utf-8-validate\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: `msbuild` failed 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:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\dotnet\Projects\firefund-cli\node_modules\utf-8-validate
gyp ERR! node -v v5.0.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:utf-8-validate [email protected] install: `node-gyp rebuild`
npm WARN install:utf-8-validate Exit status 1

Need to tell node-gyp to use MSBuild.exe

@dotnetCarpenter hey, thanks for trying it out! Did you end up getting it working? Is there anything missing from these steps? https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245

thx @mousetraps. Unfortunately I'm not sure how to tell node-gyp to use MSBuild.exe.

You comment prompted me to try just compiling a project via npm install.
I've set npm config set msvs_version 2015 --global but didn't set python as python --version already gives me 2.7.10.

I saw that you successfully compiled utf-8-validate so I cloned that repo and did npm i. The result was not very encouraging:
c:\users\dotnet\.node-gyp\5.0.0\include\node\uv-win.h(32): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory [C:\Users\dotnet\Projects\playground\utf-8-validate\b uild\validation.vcxproj]

Got .Net 4.5.2 : Release DWORD 5cbf5 (379893)

Entire output:

> [email protected] install C:\Users\dotnet\Projects\playground\utf-8-validate
> node-gyp rebuild


C:\Users\dotnet\Projects\playground\utf-8-validate {git}
{lamb} if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-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.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry.  TargetFrameworkVersion or Platfo rmToolset may be set to an invalid version number. [C:\Users\dotnet\Projects\playground\utf-8-validate\build\validation.vcxproj]
  validation.cc
c:\users\dotnet\.node-gyp\5.0.0\include\node\uv-win.h(32): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory [C:\Users\dotnet\Projects\playground\utf-8-validate\b uild\validation.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed 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:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\dotnet\Projects\playground\utf-8-validate
gyp ERR! node -v v5.0.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the utf-8-validate package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls utf-8-validate
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\dotnet\Projects\playground\utf-8-validate\npm-debug.log

Did you install the Windows sdk too when installing the build tools (this should be the default)? I believe that's where winsock2.h comes from.

I get a similar errors when building ws.

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry.  TargetFrameworkVersion or Platfo rmToolset may be set to an invalid version number. [C:\Users\dotnet\Projects\playground\ws\node_modules\bufferutil\build\bufferutil.vcxproj]
  bufferutil.cc
c:\users\dotnet\.node-gyp\5.0.0\include\node\uv-win.h(32): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory [C:\Users\dotnet\Projects\playground\ws\node_modules\ bufferutil\build\bufferutil.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed 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)
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry.  TargetFrameworkVersion or Platfo rmToolset may be set to an invalid version number. [C:\Users\dotnet\Projects\playground\ws\node_modules\utf-8-validate\build\validation.vcxproj]
  validation.cc
c:\users\dotnet\.node-gyp\5.0.0\include\node\uv-win.h(32): fatal error C1083: Cannot open include file: 'winsock2.h': No such file or directory [C:\Users\dotnet\Projects\playground\ws\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` failed 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)

@dotnetcarpenter Even after installing the Windows sdk?

Should I install the Windows 8.1 SDK with the Build Tools installer or the Windows 7 SDK when I'm on Windows 7?

Unfortunately I can not update to Windows 10 due to an unknown installation error when upgrading.

Hmm.. I somehow thought I could get things compiling without a Windows SDK but in the end I installed Windows 8.1 SDK via the installer and things seems to be working. :tada:

OS: Windows7
Node: 5.0.0
Npm: 3.3.6

@dotnetCarpenter
Hi. Installed the Build Tools 2015 provided by @mousetraps, followed instructions, tried to install selenium-webdriver (node-gyp dependant) and got the error below. Any ideas? (nodejs 4.2.2, npm 3.4, windows 10x64)
Thank you!

C:\Users\rickm\AppData\Roaming\npm\node_modules\selenium-webdriver\node_modulesutf-8-validate>if not defined npm_config_node_gyp (node "C:\Users\rickm\AppData\Roaming\npm\node_modules\npm\binnode-gyp-bin....\node_modulesnode-gyp\binnode-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.CppBuild.targets(366,5): warning MSB8003: Could not fi
nd WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid versio
n number. [C:\Users\rickm\AppData\Roaming\npm\node_modules\selenium-webdriver\node_modulesutf-8-validate\build\validat
ion.vcxproj]
validation.cc
c:\users\rickm.node-gyp\4.2.2\include\node\uv-win.h(32): fatal error C1083: Cannot open include file: 'winsock2.h': No
such file or directory [C:\Users\rickm\AppData\Roaming\npm\node_modules\selenium-webdriver\node_modulesutf-8-validate
\build\validation.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\rickm\AppData\Roaming\npm\node_modules\npm\node_modulesnode-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_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10240
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\rickm\AppData\Roaming\npm\node_modules\npm\node_modulesnode-gyp\binnode-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\rickm\AppData\Roaming\npm\node_modules\selenium-webdriver\node_modulesutf-8-validate
gyp ERR! node -v v4.2.2
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:[email protected] [email protected] install: node-gyp rebuild
npm WARN install:[email protected] Exit status 1

warning MSB8003: Could not find WindowsSDKDir variable from the registry.

Looks like you're missing the Windows 10 SDK, since you are on Windows 10. I think you can uninstall Windows SDK 8.1. Let me know if it works and I'll update the guide to be more clear.

Also, be sure to:
3.1 Check that you have .NET 4.5.1+ installed. If not then
3.2 Download and install .NET 4.5.1 (.NET 4.5.2 will also work just fine)

I have installed the windows 10 SDKs but somehow I think it failed to add it to the registry (or something like that), but I don't know how to fix it...

Run the VisualCppBuildTools_Full.exe that you downloaded from https://www.microsoft.com/en-us/download/details.aspx?id=49512 and choose Repair.

@dotnetCarpenter I finally got it working checking BOTH windows 10 SDKs and windows 8 SDK (I'm on win10) when installing the 2015 build tools. It seems that somehow the windows 10 SDKs is built on top of the windows 8 SDKs OR the windows 10 SDKs package has a bug that fails to add the correspondent registry values, and my system is simple using the windows 8 SDKs (when I added it later).

sounds weird. perhaps @mousetraps has an idea to why.

@dotnetCarpenter - I followed your Guide above with a clean install of Windows 10. The only correction I would make is that, while the Windows 8.1 SDK must be installed, the Windows 10 SDK is completely unnecessary (at least for the purpose of this issue).

@LittleBrainz thanks. I will update the guide.
@mousetraps I noticed that the link to _Microsoft Visual C++ Build Tools 2015 Technical Preview_ doesn't work anymore. Is the correct link now Microsoft Build Tools 2015 ?

@mousetraps I can't find the link to Microsoft Visual C++ Build Tools 2015. It seems that you're out of _Technical Preview_ but there is no updates on the C++ blog

@dotnetCarpenter Link was fixed on the C++ blog:
Download Visual C++ Build Tools 2015

@HoriLiu thanks! updated

Apparently, it doesn't matter what OS you're on. You just need the Windows 8.1 SDK.

@mousetraps I suspect that the Windows SDK prerequisite, is node add-on dependent. So if add-on _A_ uses some feature of Windows 10 SDK, then we must install the Windows 10 SDK, correct?

I haven't submitted the PR for this yet because I need to confirm something w/ the cpp team (and also update the link and verify Express for Desktop steps), but committed minimal required steps to this branch.
https://github.com/nodejs/node-gyp/compare/master...mousetraps:i629

It shouldn't be necessary to check the Windows SDK boxes - as explained in https://github.com/nodejs/node-gyp/issues/629#issuecomment-159808154, if you select the _default_ install, a minimal set of dependencies from both the Windows 8.1 and Windows 10 SDK will be installed (and yeah, it's confusing because neither box gets checked). We're still working out a few kinks w/ custom install, though.

Any chance you could try those steps, and let us know if you run into any issues?

What confused me about the installation steps is actually from the c++ blog images, where Windows 8.1 SDK is ticked and your initial comment was not specific about the SDKs. I honestly don't remember if I choose the default installation the first time around but I will try later and update the guide if it works.

Well ticking the sdk box _should_ (theoretically) work fine too... and it actually works fine on my machine and several VM configs I've tested (haven't been able to reproduce the other issues ppl are running into yet), but unfortunately we can't ship my machine - partly because it wouldn't scale, and partly because it got stolen today... :disappointed:

In any case, that's the reason we call it "preview" :smiley:, so we appreciate the feedback and hopefully we can work it all into the RTM release!

I've been trying to get my Windows 7 development environment set up for a while now and nothing I try seems to be working.

Steps I took:

1) Installed [email protected] (x86).

$ node -v
v4.2.3

2) Updated to [email protected]

$ npm -v
3.2.2

3) Installed [email protected] (x86)

$ python --version
Python 2.7.10

4) Installed .NET Framework 4.5.1 from here
5) Installed VC++ Build Tools 2015 from here with the default options
6) Ran required npm configurations

$ npm config set python python2.7
$ npm config set msvs_version 2015 --global

Results:

$ npm install bufferutil

> [email protected] install C:\Users\mp86743\Documents\Dev\test\node_modules\bufferutil
> node-gyp rebuild


C:\Users\mp86743\Documents\Dev\test\node_modules\bufferutil>if not defined npm_config_node_gyp (node "C:\Users\mp86743\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
gyp: C:\Users\mp86743\.node-gyp\4.2.3\common.gypi not found (cwd: C:\Users\mp86743\Documents\Dev\test\node_modules\bufferutil) while reading includes of binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Users\mp86743\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:357:16)
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_process.js:200:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\bench\\nodejs\\4.2.3\\node.exe" "C:\\Users\\mp86743\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\mp86743\Documents\Dev\test\node_modules\bufferutil
gyp ERR! node -v v4.2.3
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok
npm WARN EPACKAGEJSON [email protected] No description
npm WARN EPACKAGEJSON [email protected] No repository field.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\bench\\nodejs\\4.2.3\\node.exe" "C:\\Users\\mp86743\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "bufferutil"
npm ERR! node v4.2.3
npm ERR! npm  v3.2.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the bufferutil package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls bufferutil
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\mp86743\Documents\Dev\test\npm-debug.log

Anyone have any ideas?

I'm pretty sure that you need to install Windows 8.1 SDK. I think I had the same issue as you. According to @mousetraps the installer is trying to be smart and only install the bare minimum. But it seems that no one has gotten it to work without the Windows 8.1 SDK. Note that no one here have had to install the Windows 10 SDK...

Hi @dotnetCarpenter, thanks for the quick response. I thought that the Windows 8.1 SDK was included with the VC++ Build Tools, which is why I did not install it earlier.

In any case, I installed it from here, and it finished almost instantly, which leads me to believe that I already had it installed. I attempted an npm install bufferutil again with the same results as before.

gyp: C:\Users\mp86743.node-gyp\4.2.3\common.gypi

@Mrparkers Try deleting the .node-gyp directory, then run npm install again.

@bnoordhuis After doing that, I started getting a different error: 404 status code downloading 32-bit node.lib. I went to this issue thread to see if I could fix that one, which advised me to run npm install node-gyp@latest from C:\Users\mp86743\AppData\Roaming\npm\node_modules\npm, and now I'm running into a different error: Cannot open include file: 'stddef.h', which brought me back to this issue thread, which is the thread that brought me here.

I feel like I'm taking one step forward and two steps back with every attempt at solving my problem :cry:

The stddef.h error means you're moving in the right direction. You probably need to install VS if you haven't already (see the node-gyp README for details) and run vcvarsall.bat to configure the environment.

Or follow this guide. You don't need VS. I got the same error - see comment 155888553 in this thread. I had to install the Windows 8.1 SDK from _Microsoft Visual C++ Build Tools 2015 Technical Preview_ here http://www.microsoft.com/en-us/download/details.aspx?id=49983. I think you should uninstall your previously installed SDK and install the one that comes with Build Tools 2015. You might want to uninstall other things as well. But since Win8.1 SDK is a big download (around 4GB if I remember correctly), you might opt for just installing VS as @bnoordhuis suggest.

I installed VS 2013 Ultimate, executed VC/vcvarsall.bat, and ran npm config -g set msvs_version 2013 --global. Everything seems to be working now.

Thanks for the help @bnoordhuis and @dotnetCarpenter

I followed the guide and can't get it to work. It must be some nuance. I now installed Visual Studio 2013 Express and this worked for me.

@sponiro It depends what you had installed before. The guide should work in a "clean" environment. Microsoft Visual C++ Build Tools 2015 Technical Preview is in Technical Preview because not all kinks have been worked out. We need your bug reports before Microsoft Visual C++ Build Tools 2015 and this or another guide can be made a part of the node-gyp README.

Hello,

I have been struggling with this in a major way in the past few days (I'm lucky, it looks like it's been way longer than that for some people!). Using Windows 10, node v4.2.1, npm v3.5.2, Python v2.7.11. I keep getting an error message after doing 'npm install' (stddef.h: no such file or directory). That's after installing VS 2015 and the 8.1 SDK (in that order). I have found that file and it's apparently in the SDK 10 folder (../windows kits/10/include/10.0.10150.0/ucrt). I guess the npm installer does not know to look in the right place for this file? Maybe the SDK 10 was not registered correctly?

To try to resolve this I went back to my VS 2015 installer and tried to do "modify". I was presented with two check boxes, one for each SDK (8.1 and 10).

This confused me a bit (I'm very new to all of this so that's easy!) because I don't remember installing 10; so it came with the VS I guess? Do both SDKs come with the VS? Also, I'm not sure what checking these boxes actually mean. Update the install?

Anyway, I haven't been able yet to do this, I hope it solves it. :-(

One last question: I've seen people above say 'executed VC/vcvarsall.bat'. Where is that bat file typically located? Is it a mandatory step? It'd come between steps 4 and 5 of the above guide? How come it's not in there?

This thread has been really useful, thanks!

About the VC/vcvarsall.bat: when I try to do that (and basically whenever I try to open any VS 2015 command prompt window) I get an error message: "ERROR: cannot determine the location of the VS common tools folder". Does someone know of a fix? Thanks.

Everyone: In https://github.com/sass/node-sass/issues/1283 we figured out that binaries we compile with VS2015 do not work on Windows XP.

One has to be aware that node itself is built using VS2013 and therefore it is using version 12 of Microsoft build tools (something like PlatformToolset set to v120).

We will experiment with various values of PlatformToolset but definitely if one expects 100% compatibility with existing node engines I'd go for VS2013 now.

@saper,

  • Visual Studio 2010 => v100
  • Visual Studio 2012 => v110
  • Visual Studio 2013 => v120
  • Visual Studio 2015 => v140

VS2013 is shipped with these toolsets: v110, v120, v110_xp and v120_xp.
And VS2015 with: v120, v140, v120_xp and v140_xp.

So if you are building any C/C++ project with VS2015, you need to set PlatformToolset to v140_xp for Windows XP support. Similarly, if you are building C/C++ project with VS2013, you need to set PlatformToolset to v120_xp.

This is because Windows XP support was made optional since VS2012 (they statically compile more stuff with XP-supported binary; binary size grows). It was VS2010 which used to support Windows XP without changing the PlatformToolset.

Hope this information will remedy your confusion.

Now, like I said there, node-sass binary will be compatible if msbuild_toolset in .gypi file is set to v140_xp. Better if we figure out a way to set msbuild_toolset in .gyp file instead.

It is my understanding that release binaries of node are built with PlatformToolset set to vs120. Unfortunately, this information is not exported in the common.gypi file. I think this is the main problem here.

On the other note, the node-sass binding file for node 5.3.0 (win32; 32-bit) compiled with VS2013 has 1272832 bytes and VS2015 produced 1356546.

If you compare the binary size build with v120 and v120_xp OR v140 and v140_xp, there must be a difference according to MSDN.

1272832 is what I believe is v120 (VS2013 default) vs. 1356546 from vs140 (what we are using to build the binaries). Actually there might be no need to use _xp versions it seems.

Well, the binary size comparison I referred was supposed to be between xp and non-xp variants of same versions, and not the different versions of VS.

VS2015 has some new linker flags. For example, setting /LTCG:incremental linker flag combined with compiler flag /Ogs or /Ox provides space optimization. More on MSDN.

The toolset can be set in common.gypi like others have mentioned here: https://github.com/nodejs/node-gyp/issues/339#issuecomment-61215713 (replace v120_xp with v140_xp for VS2015).

@ogandou If you are installing _VIsual Studio 2015_ and not _Microsoft Visual C++ Build Tools 2015 Technical Preview_ then this guide is not for you. This guide is intended for people who do not wish to install an entire IDE just to compile nodejs modules.

See this short guide for different installation options: https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#environment-setup-and-configuration

Question: do Microsoft Visual C++ Build Tools 2015 include support for PlatformToolset v120 and/or 12.0 tools?

Hi guys,

I'm having these troubles too. i have followed the instructions here with a clean Win7 install, and i still get errors.
@dotnetCarpenter @mousetraps , Can you help?

C:\Users\YONI\.node-gyp\4.2.6\include\node\v8.h(18): fatal error C1083: Cannot
open include file: 'stddef.h': No such file or directory [D:\Dev\getinvolved\cl
ient\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\no
de_modules\ws\build\validation.vcxproj]

On Mon, 25 Jan 2016, Yoni Dor wrote:

Hi guys,

I'm having these troubles too. i have followed the instructions here with a clean Win7 install, and i still get errors.
@dotnetCarpenter @mousetraps , Can you help?

Do you have Windows SDK installed?

@saper, I have done everything as mentioned in the first post of this thread. I have installed _Windows SDK 8.1_ from _Microsoft Visual C++ Build Tools 2015 Technical Preview_ installation. Should i try to reinstall?

@yonidor can you post the result of npm config -g list here, your Windows version and the name of the node package you are trying to compile?

@dotnetCarpenter Sure,
npm config -g list output:

; cli configs
global = true
user-agent = "npm/2.14.12 node/v4.2.6 win32 x64"

; globalconfig C:\Users\YONI\AppData\Roaming\npm\etc\npmrc
msvs_version = "2015"

; builtin config undefined
prefix = "C:\\Users\\YONI\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = D:\Dev\Angular2\GetInvolved
; HOME = C:\Users\YONI
; 'npm config ls -l' to show all defaults.

Windows version is Windows Professional 7 SP1 64bit
the node packages that fail are: [email protected] and [email protected]

@dotnetCarpenter , No idea for me? :(

Sorry, I had a coffee accident with my laptop. The output looks right.
Does D:\Dev\getinvolved\cl ient\node_modules\karma\node_modules\socket.io\node_modules\socket.io-client\no de_modules\ws\build\validation.vcxproj exist? If not, you probably had a bad npm download.
If yes, find the reference to stddef.h in validation.vcxproj. Does it exist? If not, you probably had a bad npm download.

Try deleting the node_modules folder and npm i again. If it doesn't work, check out the socket.o-client github project and see if the file is in the repository at all. If not, then create a github issue.

had to update from npm 3.3.6 to npm 3.6.0 to make it work

Hmm.. I got it to work with npm 3.3.6 but it's true that the package itself could use a feature from newer npm version, hence you need npm 3.6.0+

Hi ,
did like mentioned above, installed windows 8.1 skd (compiler came with vs 2015 installation, BTW only done because of nw-gyp errors ), set the studio version, now the error was about missing header files (stddef.h etc) , looking it up i realized that they only resided in windowsKits\10\include, tried to copy them and got lots of typecast errors , so are there other header files vor the 8.1 sdk ( read on the ms-page that they redisigned the whole system with VS 2015 ), and if where do i get them from ???

OK now definitely found out that Windows 10 headers wont work :+1: https://naughter.wordpress.com/2015/05/15/changes-in-the-windows-10-sdk-compared-to-windows-8-1-part-one/
but i cant find a download for the corresponding 8.1 files, do i really have to do a manual install of VS2013 ( on a virtual machine probably ) or is there any chance of getting just the missing header files ???
Would be super if anybody out there could just mail them to me.

@treh1966 What npm module are you trying to compile? Seems they have an unordinary build step.

Tried to compile node-escpos.
Seems like i could only do it the automatic way, because even when i download the project manually from github, there is e.g. no binding.gyp file.

Tried to compile node-escpos.
Seems like i could only do it the automatic way, because even when i
download the project manually from github, there is e.g. no binding.gyp
file.

Am 07.02.2016 um 13:03 schrieb Jon Ege Ronnenberg:

@treh1966 https://github.com/treh1966 What npm module are you trying
to compile? Seems they have an unordinary build step.

—
Reply to this email directly or view it on GitHub
https://github.com/nodejs/node-gyp/issues/802#issuecomment-181000576.

@treh1966 there is at least 3 different node-escpos packages in the wild. Which one is it? Link please

Have to admit i am a little bit confused, as i also found several packages with escpos e.g. on github, which all claim to be installed by npm install node-escpos, so finally i dont know which one npm chooses.
the one i tried to download was the one from https://github.com/StadiumRunner/node-escpos, while the one listed in npm search seems to be https://github.com/song940/node-escpos
descriptions dond really give any hints on differences .

just found out, with npm view node-escpos that tthats something totally different again:
https://github.com/zinfo-ca/node-escpos

which dates back to 2013 and doesnt seem to be very useful, so how do i npm e.g. the Stadium runner one

OK, now when (which i just found out to be possible ) when trying to install from the dl directory it seemed to work
I:\Registrierkassen\xmltests>npm install I:\Registrierkassen\apptest\Downloads\n
ode-escpos-masterStadiumRunnernode-escpos-master
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data

npm WARN package.json [email protected] No license field.

[email protected] install I:\Registrierkassen\xmltestsnode_modulesnode-escposnode_m
odules\usb
node-pre-gyp install --fallback-to-build

[usb] Success: "I:\Registrierkassen\xmltestsnode_modulesnode-escposnode_modul
es\usb\src\binding\usb_bindings.node" is installed via remote
[email protected] node_modulesnode-escpos
├── [email protected]
├── [email protected]
└── [email protected] ([email protected])

will immideately try using it , and report back if wanted

@dotnetCarpenter
Please help
Ok this tome i gave node-printer (http://github.com/tojocky/node-printer) a try
and succeded ??? in compiling , but still get no Release Folder or .node file
and require('printer') crashes.
BTW i simply copied the whole master folder to my node_modules folder, or is there any other procedure to follow ?
I:\Registrierkassen\apptest\Downloadsnode-printer-tojockeynode-printer-master>
nw-gyp build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
(node) child_process: options.customFds option is deprecated. Use options.stdio
instead.
gyp info spawn C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
Die Projekte in dieser Projektmappe werden nacheinander erstellt. Um eine parall
ele Erstellung zu ermöglichen, müssen Sie den Schalter "/m" hinzufügen.
gyp info ok

I:\Registrierkassen\apptest\Downloadsnode-printer-tojockeynode-printer-master>

@treh1966 You should install from the github repo. npm accepts git urls.

a < git remote url > that resolves to a folder containing a program described by a package.son file
_https://docs.npmjs.com/cli/install_

npm install --save https://github.com/tojocky/node-printer.git. But in this case, the package is in npm as printer - so just do npm i printer --save to save the package as a dependency in your package.json.

I'm not currently on Windows, so can not test, but your compiling effort looks successful.

gyp info it worked if it ends with ok
...
gyp info ok

@dotnetCarpenter
that didnt work either, getting lots og errors ( onvarious local directories and the url like:
...
npm ERR! git clone --template=D:\Benutzer\Administrator\AppData\Roaming\npm-cach
e_git-remotes_templates --mirror https://github.com/tojocky/node-printer.git D
:\Benutzer\Administrator\AppData\Roaming\npm-cache_git-remotes\git-https-github
-com-tojocky-node-printer-git-9b5ed545: undefined
npm ERR! git clone --template=D:\Benutzer\Administrator\AppData\Roaming\npm-cach
e_git-remotes_templates --mirror https://github.com/tojocky/node-printer.git D
:\Benutzer\Administrator\AppData\Roaming\npm-cache_git-remotes\git-https-github
-com-tojocky-node-printer-git-9b5ed545: undefined
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Filesnodejsnode.exe" "D:\Benutzer\Administrator
\AppData\Roaming\npmnode_modules\npm\bin\npm-cli.js" "install" "--save"
"https://github.com/tojocky/node-printer.git"
npm ERR! node v4.2.6
npm ERR! npm v3.7.1
npm ERR! code ENOGIT

npm ERR! not found: git
....

So what i did is download the whole master branch to a local directory and point npm to that directory.
Now no matter which version of msvs i specify ( which worked great with nw-gyp) i get the missing header files errors ( stddef.h etc )

Do i have to have a clean npm install of the original to do a nw-gyp rebuild ??

BTW i found a precompiles windows version, but dont know, and found no clues how to use the directory structure, which contains the .node files ?

Thanks in advance
Thomas

@treh1966 You don't have git installed.

npm ERR! code ENOGIT
npm ERR! not found: git'

You probably need git to install from a local git repository.

What happens when you do a standard install? npm install printer

I can see on the appveyor.com build log that node-printer compiles successfully with MSBuild 12.0, which I'm pretty sure comes with Visual Studio 2013.

Please check your PATH and that node-printer compiles with Visual Studio 2015.

2 Check that python is in your path by writting python --version in the console.

Thanks @dotnetCarpenter and @mousetraps !! Installing the missing Windows 8.1 SDK did make it work.

Installed both Windows 8.1 SDK and win 10 SDK... followed all the instructions and still not working

``` .cmd
Hadi@ThinkPad MINGW64 ~/Desktop/New folder/utf-8-validate (master)
$ npm i
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Jade has been renamed to pug, please install th e latest version of pug instead of jade
npm WARN deprecated [email protected]: to-iso-string has been deprecated, use @segment/to-iso-string instead.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

[email protected] install C:\Users\Hadi\Desktop\New folderutf-8-validate
node-gyp rebuild

C:\Users\Hadi\Desktop\New folderutf-8-validate>if not defined npm_config_node_g yp (node "C:\Program Filesnodejsnode_modules\npm\binnode-gyp-bin\....node_ modulesnode-gyp\binnode-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.
validation.cc
win_delay_load_hook.c
C:\Program Filesnodejsnode_modules\npmnode_modulesnode-gyp\src\win_delay_loa d_hook.c(34): error C2373: '__pfnDliNotifyHook2': redefinition; different type m odifiers [C:\Users\Hadi\Desktop\New folderutf-8-validate\build\validation.vcxpr oj]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\delayimp.h(134) : note: see declaration of '__pfnDliNotifyHook2'
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 Filesnodejsnode_modules\ npmnode_modulesnode-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_proces s.js:204:12)
gyp ERR! System Windows_NT 10.0.10586
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:\Users\Hadi\Desktop\New folderutf-8-validate
gyp ERR! node -v v6.3.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\ node_modules\npm\bin\npm-cli.js" "i"
npm ERR! node v6.3.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the utf-8-validate packag e,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs utf-8-validate
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls utf-8-validate
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Hadi\Desktop\New folderutf-8-validate\npm-debug.log

```

@Almusamim you're running in to our __pfnDliNotifyHook2 problem which has been covered pretty extensively on this issue tracker (not that I'm suggesting it's easy to identify!). In order to use the latest release of Visual Studio 2015 you need to get the latest version of node-gyp which comes with the latest v2 and v3 releases of npm. You should be able to run npm i npm@latest -g to get the latest version. Our next v6 release of Node.js should come with this too.

@ dotnetCarpenter

I am new to node js. I am running into the node-gyp errors this article described. My OS is Win8.1 and I have followed all the instructions but Step6/ in your guide at the beginning.
Can you explain what do you mean by "Do npm i in what-ever project with node-gyp as a dependency without seeing weird error messages"?

For example, currently, after I have performed your step 1-5, I used this command, "npm install -g TheApp". How do I incorporate your step 6 into this install command?

BTW, I have errors related to kerberos when I used the above generic install command which then led to the same node-gyp errors shown in this article.
Also, I did not install node-gyp separately, the app I tried to install w/o success seemed to install this module.
When I look at the user/appdata/roaming folder, node-gyp is created in a separate .node-gyp folder and not within the subfolder of npm/modules folders inside roaming. Is that (strange location of .node-gyp folder) normal?
Should I install node-gyp module (globally) to eradicate these errors?

Please advise.

Thanks in advance,
Sorcerer

Step 6 means everything is done and there should be no errors. If you are getting something else I'd file another bug. Kerberos errors suggest you might need proxy authentication to download stuff, I think this is out of scope of node-gyp

Thank you all for paticipating the discussion and share your insights.
I also met the problem while installing a native node module, and eventually, just solved it by installing Visual C++ Build Tool from npm-gyp official documents Microsoft's Node.js Guidelines for Windows, by which installed

  • Windows 8.1 SDK
    (althought I'm using Windows 10, an error message indicated the missing of 8.1 SDK )
  • .NET Framework SDK.

    I also installed the other two, but I'm not sure if they were neccessary, which are

  • Windows 10 SDK
  • ATL/MFC SDK.

With other issues like Python version and PATH settings addressed, npm started to work normally.

Just like WillingAC, I also followed the official document from Microsoft's Node.js Guidelines for Windows, but I am still having problems when I tried to compile the Couchbase SDK for node (couchnode). The errors I ran into are:

uv-plugin-all.obj : error LNK2001: unresolved external symbol __imp_WSAGetLastError [D:\Development\NodeJs\couchbase-te st\node_modules\couchbase\build\couchbase_impl.vcxproj] uv-plugin-all.obj : error LNK2001: unresolved external symbol __imp_getsockopt [D:\Development\NodeJs\couchbase-test\no de_modules\couchbase\build\couchbase_impl.vcxproj] uv-plugin-all.obj : error LNK2001: unresolved external symbol __imp_recv [D:\Development\NodeJs\couchbase-test\node_mod ules\couchbase\build\couchbase_impl.vcxproj] D:\Development\NodeJs\couchbase-test\node_modules\couchbase\build\Release\couchbase_impl.node : fatal error LNK1120: 3 unresolved externals [D:\Development\NodeJs\couchbase-test\node_modules\couchbase\build\couchbase_impl.vcxproj]

After some Google searches, I found that I needed to link to WS2_32.Lib. I checked the SDK folder under C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86 (and x64) and the file is there. So, somehow npm-gyp just couldn't pass the location to msbuild. I also tried setting an environment variable ILink_LibraryPath and pointed it to WS2_32.Lib before compiling the module, but it didn't help. I am at lost!

@toyssamurai You should report that to the maintainers of the couchbase module, it's not a node-gyp issue. Make sure you're using the latest version, it might have been fixed already.

I tired to find the MS standalone compiler, but when I opened the link it says the account expired. Is there any other link to download MS C++ standalone compiler.

In VS2017 & VS2019 MS did not release a stand alone compiler. There is a CLI only "Built Tools" SKU at - https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16

I did all the tasks described above to recompile node-java, in order to install node-jdbc. But I sill fail, even though I did all the described measures above: installed python, have .Net 4.5.1, installed Visual Studio 2015, installed Build Tools, set "npm config -g set msvs_version 2015" and also tried many other measures described in other threads.
But, when I try to recompile node-java, I get the following error message:

gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\EigeneProgrammenodejsnode_modules\npmnode_modulesnode-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:223:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\EigeneProgramme\nodejs\node.exe" "C:\EigeneProgramme\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Workspaces\Lehre\WE2node-jdbc-example-masternode_modules\jdbcnode_modules\java
gyp ERR! node -v v12.14.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

Has anybody an idea, what else I can do? Thanks for your help in advance!
John

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jhermsmeier picture jhermsmeier  Â·  3Comments

kimown picture kimown  Â·  3Comments

alexeyvo picture alexeyvo  Â·  3Comments

adrianescat picture adrianescat  Â·  3Comments

Yamakaky picture Yamakaky  Â·  3Comments