Cannot install node modules that require compilation on Windows 7 x64/VS2012
Asked Answered
T

17

195

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 [email protected]
gyp info using [email protected] | 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.

Tryptophan answered 11/1, 2013 at 12:40 Comment(7)
Have you tried running vcvarsall.bat instead of trying to set up your environment manually?Palladous
No success. Still "MSB3411: Could not load the Visual C++ component "VCBuild.exe"."Tryptophan
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 directoryTryptophan
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.Geryon
This was posted 2015-11-19, and IT WORKS! (Many good suggestions on this thread but no joy) github.com/nodejs/node-gyp/issues/629#issuecomment-158163655 The procedure installs Build Tools 2015, not VS2012.Swoosh
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 and hereSst
Best answer: https://mcmap.net/q/128004/-cannot-install-node-modules-that-require-compilation-on-windows-7-x64-vs2012Turgent
A
152

Try that - will set it globally:

npm config set msvs_version 2012 --global
Astonish answered 14/3, 2014 at 16:44 Comment(7)
Perfect! Fixed all my problems!Antiperiodic
Excellent, I was getting the error when running a set of scripts that invoked npm deep in the bowels. I didn't want to modify the scripts , so this was the best option for meMckenna
This should be the recommended answer, worked like a charm on Windows 10Masthead
Doesn't work. error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found.Shepard
on a Windows 10 PC with VS2017 only - I used VS2017 setup to also install the 2015 VC build tools. then torazaburo's fix worked :) actually catalint's answer below looks better but I've not tried it....Gynandromorph
I'd add +100 if posible ... Thanks a lotNiddering
How can I undo this configuration? What's the default?Crossjack
J
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

Jamshedpur answered 31/5, 2013 at 9:40 Comment(10)
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!Perineurium
@Perineurium superuser.com/questions/372203/… it worked for me with 1 dash shrugJamshedpur
Thanks for this; the npm install command got it working for me. One dash worked for me as well.Mathur
It should be --msvs-version=2012Extranuclear
This worked amazingly with my Windows 7 x64 install! Thanks Microsoft (for being dicks)!Spasmodic
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=2012Cloninger
npm install --msvs_version=2013 did the trick for me - thanks a lot!Enwrap
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 :)Shebashebang
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 errorStave
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 and hereSst
M
61

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

Meacham answered 13/8, 2015 at 11:39 Comment(7)
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: github.com/nodejs/node-gypArdellaardelle
updated answer to include the new readme from node-gyp, thanks @MichaelK.Meacham
I installed VS2015 and ran this command npm config set msvs_version 2015 --global which works as wellYuki
Similarly, installing Microsoft Build Tools 2015 and running npm config set msvs_version 2015 --global worksUrbain
v3 (npm install --global windows-build-tools) worked great for me on Windows 10.Danieledaniell
v3 (npm install --global --production windows-build-tools in Administrator shell) still worked for me on Windows 10Moolah
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.Ferullo
P
41

just add --msvs_version=2012

node-gyp rebuild --msvs_version=2012

or

node-gyp configure --msvs_version=2012
node-gyp build 
Phenothiazine answered 14/4, 2013 at 15:14 Comment(2)
Same answer as above.Spasmodic
I answered first, look at the date :)Phenothiazine
I
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.

Ibnrushd answered 5/4, 2013 at 9:57 Comment(5)
THANKS!!! MASSIVE KUDOS ps you also have to add Python to your path: #4621755Starstarboard
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!Adscription
This walkthrough is the best up til now. Nontheless, all this base64 problem is totally unnecessary and annoying!Maunder
Oh yeah, this is what I needed. Best walk through I've found and it works!Agnusago
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'Hereafter
V
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.

Veradis answered 15/11, 2016 at 17:18 Comment(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.Erective
L
12

on windows 8, it worked for me using :

npm install -g node-gyp -msvs_version=2012

then

npm install -g restify
Leucine answered 29/1, 2014 at 3:55 Comment(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.Teddi
T
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.

Triceps answered 5/12, 2013 at 19:2 Comment(0)
S
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

Sherylsheryle answered 24/5, 2015 at 8:7 Comment(0)
S
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
Swedenborgian answered 20/9, 2014 at 18:2 Comment(2)
if this failed for you, check do you have environment variable PYTHON=c:\Python27\python.exe, and https://mcmap.net/q/130095/-testacular-install-fails-no-vcbuild-exeBoggess
npm install -g node-gyp@latest ?Chairborne
Y
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
Youth answered 1/11, 2013 at 22:1 Comment(1)
Visual Studio 2012 also comes with 'Developer Command Prompt for VS2012' so you don't have to customize your env PATH variableStillborn
C
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

Coel answered 5/3, 2013 at 13:8 Comment(3)
Here is the SDK link: microsoft.com/en-us/download/details.aspx?id=11310Concourse
The reason for it not finding VCBuild is that it was replaced with MSBuild in 2010, according to codeproject.com/Articles/562386/…Roselinerosella
See my answer below. vcbuild.exe is required but many environment variables must be set and the node-gyp project doesn't document them.Triceps
B
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
Betsey answered 27/5, 2015 at 16:36 Comment(0)
M
0

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

Monitory answered 6/6, 2014 at 7:33 Comment(1)
can you elaborate more on how did you switched to x86 ?Tangible
E
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 :)

Elodea answered 23/9, 2014 at 18:17 Comment(0)
U
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.

Underact answered 14/4, 2015 at 15:14 Comment(0)
P
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.

Periodontal answered 28/12, 2015 at 16:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.