194

I cannot install any of the modules that require compilation. All they fail with the following error:

MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". ...

My environment:

  • Windows 7 Enterprise x64, version 6.1.7601
  • node x86 0.8.16
  • npm 1.2.0
  • node-gyp 0.8.2
  • Visual Studio 2012 and numerous packages

Related environment variables:

Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShel l\v1.0;C:\Program Files\TortoiseGit\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\tools;c:\tools\node

No INCLUDE, LIB, LIBPATH, etc.

I did a short investigation of the issue and figure out that with the following setup the manual compilation (calling VCBuild.exe and msbuild.exe directly) succeed for the manually cloned git://github.com/einaros/ws.git:

SET Configuration=Release
SET PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\VC\vcpackages
SET PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\bin;%PATH%
SET PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\Common7\IDE;%PATH%
SET PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%
SET PATH=%SystemRoot%\system32;%PATH%

SET INCLUDE=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\include
SET INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE%

SET LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Lib
SET LIB=%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\lib;%LIB%

SET MSBUILD="%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"

VCBuild.exe C:\Tools\node\ws\build\bufferutil.vcproj "Release|Win32" /useenv
VCBuild.exe C:\Tools\node\ws\build\validation.vcproj "Release|Win32" /useenv
%MSBUILD% build/binding.sln /verbosity:diagnostic /nologo /p:Configuration=Release;Platform=Win32

I've tried to call node-gyp with the same variables and it failed:

C:\!> git clone https://github.com/einaros/ws.git
C:\!> cd ws
C:\!\ws>node-gyp configure
...
C:\!\ws>node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@0.8.2
gyp info using node@0.8.16 | win32 | ia32
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\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=Win32' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\User\.node-gyp\0.8.16\deps\uv\include\uv.h(55): fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory [C:\!\
ws\build\binding.sln]
C:\Users\User\.node-gyp\0.8.16\deps\uv\include\uv.h(55): fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory [C:\!\
ws\build\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
gyp ERR! stack     at ChildProcess.onExit (c:\Tools\node\node_modules\node-gyp\lib\build.js:255:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack     at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "c:\\Tools\\node\\\\node.exe" "c:\\Tools\\node\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\!\ws
gyp ERR! node -v v0.8.16
gyp ERR! node-gyp -v v0.8.2
gyp ERR! not ok

Maybe you will have some ideas about it?

Thanks.

Alex Netkachov
  • 12,041
  • 5
  • 44
  • 78
  • Have you tried running `vcvarsall.bat` instead of trying to set up your environment manually? – JohnnyHK Jan 11 '13 at 13:51
  • No success. Still "MSB3411: Could not load the Visual C++ component "VCBuild.exe"." – Alex Netkachov Jan 11 '13 at 14:02
  • BTW, I have better results with "C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin\SetEnv.Cmd": fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory – Alex Netkachov Jan 11 '13 at 14:06
  • 2
    I have just finally got bcrypt to install which requires building on win7 64 bit environment, it's been a pain in the neck to get sorted. With my situation I followed the instructions for bcrypt and for node-gyp. The clincher for me was installing the Microsoft Windows 7 SDK and .Net 4 framework. Once that was installed (and I had restarted my shell) I found I could compile everything via the install for bcrypt. So I was just wondering if you installed the SDK? I ask as you didn't mention it in your list. – Metalskin Jan 13 '13 at 22:01
  • 1
    This was posted 2015-11-19, and IT WORKS! (Many good suggestions on this thread but no joy) https://github.com/nodejs/node-gyp/issues/629#issuecomment-158163655 The procedure installs Build Tools 2015, not VS2012. – dkloke Nov 22 '15 at 09:54
  • No longer work with newer nodejs and vs2012 but vs2015 also have yet another error `pfnDliNotifyHook2`. **Fixed** this with `npm -g install npm@next` with vs2015. Refer to [here](https://github.com/nodejs/node-gyp/issues/972) and [here](http://stackoverflow.com/a/38647149/186334) – CallMeLaNN Jul 28 '16 at 21:40
  • Best answer: https://stackoverflow.com/a/31987161/11236 – ripper234 May 23 '17 at 14:12

17 Answers17

150

Try that - will set it globally:

npm config set msvs_version 2012 --global
srfrnk
  • 2,289
  • 1
  • 14
  • 30
144

To do it without VS2010 installation, and only 2012, set the msvs_version flag:

node-gyp rebuild --msvs_version=2012

npm install <module> --msvs_version=2012

as per @Jacob comment

npm install --msvs_version=2013 if you have the 2013 version

amd
  • 18,048
  • 6
  • 45
  • 64
Alex
  • 5,442
  • 6
  • 39
  • 61
  • 3
    Although I believe the second command should have two hyphens on its parameter, too - I put two hyphens in for it and it worked. This got me past my npm install errors - thanks! – Dullroar Oct 06 '13 at 17:15
  • 1
    @Dullroar http://superuser.com/questions/372203/whats-the-difference-between-one-dash-and-two-dashes-for-command-prompt-paramet it worked for me with 1 dash *shrug* – Alex Oct 08 '13 at 10:10
  • Thanks for this; the `npm install` command got it working for me. One dash worked for me as well. – Seiyria Feb 04 '14 at 15:29
  • It should be --msvs-version=2012 – RaduM Feb 26 '14 at 22:16
  • This worked amazingly with my Windows 7 x64 install! Thanks Microsoft (for being dicks)! – Blairg23 Oct 09 '14 at 16:19
  • Worked for me on Windows 8.1 64bit once I installed python and trying to install `jest-cli` using `npm install jest-cli --save-dev --msvs_version=2012` – Wilbert van de Ridder Mar 02 '15 at 16:14
  • npm install --msvs_version=2013 did the trick for me - thanks a lot! – user2523784 Jun 25 '15 at 14:11
  • Sometimes you forget to open a new command line to run npm install after installing msvs 2013 and you keep trying and turn your computer off. Next day when you try it just works. Happy configs :) – kta Aug 29 '15 at 01:15
  • Is it possible to install a module that requires compilation without visual studio ? I installed visual studio in the past and now I dont know how to run the `npm install` and fix this error – RPDeshaies Dec 17 '15 at 00:49
  • No longer work with newer nodejs and vs2012 but vs2015 also have yet another error `pfnDliNotifyHook2`. **Fixed** this with `npm -g install npm@next` with vs2015. Refer to [here](https://github.com/nodejs/node-gyp/issues/972) and [here](http://stackoverflow.com/a/38647149/186334) – CallMeLaNN Jul 28 '16 at 21:38
60

Update v3: https://www.npmjs.com/package/windows-build-tools

npm install --global windows-build-tools

downloads and installs Visual C++ Build Tools 2015, provided free of charge by Microsoft. These tools are required to compile popular native modules. It will also install Python 2.7, configuring your machine and npm appropriately.

Update v2:

node-gyp updated their readme to include HOW-TO for windows

Original:

No need for the entire visual studio, you can download just the build tools

Microsoft Build Tools 2013 : http://www.microsoft.com/en-us/download/details.aspx?id=40760

run cmd to set global flag to use the 2013 version:

npm config set msvs_version 2013 --global

after this everything should be back to normal and your npm install / node-gyp rebuild will work

catalint
  • 1,757
  • 16
  • 17
  • The Build Tools do not include the Platform Toolsets ... sadly there seems to be no way around installing Visual Studio :( also read the installation instructions for node-gyp on windows: https://github.com/nodejs/node-gyp – Michael K. Nov 21 '15 at 12:01
  • updated answer to include the new readme from node-gyp, thanks @MichaelK. – catalint Dec 21 '15 at 14:18
  • 2
    I installed VS2015 and ran this command `npm config set msvs_version 2015 --global` which works as well – JRulle Jan 06 '16 at 21:06
  • Similarly, installing Microsoft Build Tools 2015 and running `npm config set msvs_version 2015 --global` works – Jon Onstott Jan 03 '17 at 01:55
  • v3 (npm install --global windows-build-tools) worked great for me on Windows 10. – Ryan Shillington Jan 28 '17 at 04:33
  • v3 (npm install --global --production windows-build-tools in Administrator shell) still worked for me on Windows 10 – Eric Apr 10 '18 at 06:44
  • 1
    Running the 'windows-build-tools' as stated above using NPM (Node Package Manager) _DID_ work for me, but only when running it through Microsoft **PowerShell**. This is a Windows utility provided by Microsoft for more than 10 years. It has the Administrative rights required to run the Build Tools. Locate PowerShell, right click on it, and run as Administrator. Note that running the standard CMD prompt as Admin may _also_ work, but I had success with **PowerShell**. The extra tooling and UNIX-like command support may be part of why it works, though running it as Admin was the bigger solution. – Michael M May 16 '18 at 21:36
41

just add --msvs_version=2012

node-gyp rebuild --msvs_version=2012

or

node-gyp configure --msvs_version=2012
node-gyp build 
msulhas
  • 551
  • 5
  • 13
21

I had the same issue when trying to install a package for Node.js. After some extensive googeling I found this walktrough: https://github.com/TooTallNate/node-gyp/wiki/Visual-Studio-2010-Setup

When I had followed these steps I could use "npm install" without any issues.

  • THANKS!!! MASSIVE KUDOS ps you also have to add Python to your path: http://stackoverflow.com/questions/4621255/how-do-i-run-a-python-program-in-the-command-prompt-in-windows-7 – sidonaldson Aug 13 '13 at 16:08
  • If you already have Visual Studio installed then the top-voted answers may work, however if you don't have it at all then you need this answer. Thanks! – JD Smith Jan 06 '14 at 04:37
  • This walkthrough is the best up til now. Nontheless, all this base64 problem is totally unnecessary and annoying! – Benedikt Jul 22 '14 at 10:19
  • Oh yeah, this is what I needed. Best walk through I've found and it works! – Corin Aug 27 '14 at 19:06
  • I have a Node.js project using the Couchbase SDK for Node that builds fine on my work computer, which has Visual Studio 2008, 2010, and 2012. I wanted to test installation for "hobbyists" without any copies of Visual Studio. I uninstalled all Microsoft development tools and SDKs from my home computer, and tried various "Express" options. Only after I followed these steps documented by TooTallNate was I able to build the Couchbase binaries for Windows, including this step to rebind for operation as a "desktop" application using NW.js (formerly node-webkit): 'nw-gyp rebuild --target=0.12.0' – Rick Rutt Apr 08 '15 at 01:19
13

Thanks to @felixrieseberg, you just need to install windows-build-tools npm package and you are good to go.

npm install --global --production windows-build-tools

You won't need to install Visual Studio.

You won't need to install Microsoft Build Tools.

From the repo:

After installation, npm will automatically execute this module, which downloads and installs Visual C++ Build Tools 2015, provided free of charge by Microsoft. These tools are required to compile popular native modules. It will also install Python 2.7, configuring your machine and npm appropriately.

Windows Vista / 7 requires .NET Framework 4.5.1 (Currently not installed automatically by this package)

Both installations are conflict-free, meaning that they do not mess with existing installations of Visual Studio, C++ Build Tools, or Python.

Ramazan Polat
  • 4,788
  • 1
  • 35
  • 60
  • 1
    You are absolutely right. I treid VS, npm and gyp versions for hours, but without .NET 4.5.1 (exactly) there is absolutely no way to get it compiled. That also explains why it will work with most VS-Installations, as they come with .NET pre-bundled. – Xan-Kun Clark-Davis Jun 02 '17 at 19:28
12

on windows 8, it worked for me using :

npm install -g node-gyp -msvs_version=2012

then

npm install -g restify
amgohan
  • 1,278
  • 2
  • 13
  • 23
  • 1
    I don't think that the *restify* package has anything to do with the OP question, *restify* is only one of several packages affected by the same issue. – adelriosantiago Oct 12 '15 at 03:39
5

After DAYS of digging, someone on IRC suggested that I try to use the

Windows 7.1 SDK Command Prompt

Shortcut (links to C:\Windows\System32\cmd.exe /E:ON /V:ON /T:0E /K "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd"). I think you MUST have the older 7.1 SDK (even on Windows 8.1) because the newer ones use msbuild.exe instead of vcbuild.exe which is what node-gyp wants even though it's twice as old as node at this point :/

Once in that prompt, I had to run the following to get x86 context because the compiler was throwing as error otherwise about architecture:

setenv.cmd /Release /x86

THEN I was able to successfully run npm commands that were trying to use node-gyp to recompile things.

rainabba
  • 3,067
  • 27
  • 29
4

I had the same isuee and did all the magic above, the only thing that did the magic for me is from https://github.com/atom/atom/issues/2435

"Because the --msvs_version=2013 is not passed to node-gyp when it's run by the build script. Set the GYP_MSVS_VERSION = 2013 env variable and it should work after."

Bang! it worked

amitgur
  • 370
  • 4
  • 10
3

On Windows This helped me: (credits goes to) https://github.com/TooTallNate/node-gyp/wiki/Updating-npm%27s-bundled-node-gyp I tried MINGW32, but with no success.

on cmd.exe

$ cd "C:\Program Files\nodejs\node_modules\npm"
$ npm install -g node-gyp@latest
danielpopa
  • 778
  • 13
  • 25
2

For windows 8 64-bit, installing zmq and protobuf, the following worked for me: Install Visual Studio 2012 On the command line:

SET VisualStudioVersion=11.0
npm install zmq
npm install protobuf
ihm
  • 2,233
  • 1
  • 12
  • 5
  • Visual Studio 2012 also comes with 'Developer Command Prompt for VS2012' so you don't have to customize your env PATH variable – strider Dec 06 '13 at 22:50
1

I think the solution is to download install Microsoft windows sdk for server 2008 with .net framework 3.5

or just install Visual studio 2008.

The issue is for windows builds node-gyp executes vcbuid.exe file, and for some reason it can't find it.

Thanks

  • Here is the SDK link: http://www.microsoft.com/en-us/download/details.aspx?id=11310 – roeland Mar 10 '13 at 12:36
  • 2
    The reason for it not finding VCBuild is that it was replaced with MSBuild in 2010, according to http://www.codeproject.com/Articles/562386/Lessons-learned-migrating-to-Visual-Studio-2012-an – UnPlan2ned Sep 29 '13 at 20:57
  • See my answer below. vcbuild.exe is required but many environment variables must be set and the node-gyp project doesn't document them. – rainabba Dec 05 '13 at 19:03
1
  1. Install Python 2.7 (not 3.x)
  2. Add the path to the directory containing vcbuild.exe on your environment variable PATH
  3. If you need vcbuild.exe get it here https://github.com/kin9puppy/vcbuildFixForNode
kingPuppy
  • 2,459
  • 1
  • 16
  • 16
0

After a long struggle, I've switched my node architecture to x86 and it worked like a charm.

Community
  • 1
  • 1
0

I had also a lot of problem to compile nodejs zmq.

For the problem with with vcbuild.exe, just add it to the PATH

For other problems I could compile just using Windows 7.1 SDK Command Prompt

(Menu Programs -> Microsoft Windows SDK v7.1 -> Windows 7.1 SDK Command Prompt)

And from the prompt:

npm install zmq

That's works :)

Kleyson Rios
  • 1,327
  • 3
  • 15
  • 43
0

in cmd set Visual Studio path depending upon ur version as

Visual Studio 2010 (VS10): SET VS90COMNTOOLS=%VS100COMNTOOLS%

Visual Studio 2012 (VS11): SET VS90COMNTOOLS=%VS110COMNTOOLS%

Visual Studio 2013 (VS12): SET VS90COMNTOOLS=%VS120COMNTOOLS%

In node-master( original node module downloaded from git ) run vcbuild.bat with admin privileges. vcbild.bat will generate windows related dependencies and will add folder name Release in node-master

Once it run it will take time to build the files.

Then in the directory having .gyp file use command

node-gyp rebuild --msvs_version=2012 --nodedir="Dive Name:\path to node-master\node-master"

this will build all the dependencies.

niket
  • 58
  • 7
0

I solved this problem on windows 8 and windows 10 pro with this tutorial. I try a lot of times to solve this problem with many different solutions, but only worked for me with this: http://www.serverpals.com/blog/building-using-node-gyp-with-visual-studio-express-2015-on-windows-10-pro-x64 I notice that i didn't use nodist to control the node version like this tutorial, I use NVM and worked fine, i don't test this tutorial with nodist. I used node 5.2.0.

Marco Blos
  • 785
  • 6
  • 21