Cannot install node modules that require compilation on Windows 7 x64/VS2012
node.jsVisual Studio-2012Node Gypnode.js Problem Overview
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.
node.js Solutions
Solution 1 - node.js
Try that - will set it globally:
npm config set msvs_version 2012 --global
Solution 2 - node.js
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
Solution 3 - node.js
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
Solution 4 - node.js
just add --msvs_version=2012
node-gyp rebuild --msvs_version=2012
or
node-gyp configure --msvs_version=2012
node-gyp build
Solution 5 - node.js
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.
Solution 6 - node.js
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.
Solution 7 - node.js
on windows 8, it worked for me using :
npm install -g node-gyp -msvs_version=2012
then
npm install -g restify
Solution 8 - node.js
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.
Solution 9 - node.js
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
Solution 10 - node.js
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
Solution 11 - node.js
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
Solution 12 - node.js
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
Solution 13 - node.js
- Install Python 2.7 (not 3.x)
- Add the path to the directory containing
vcbuild.exe
on your environment variablePATH
- If you need
vcbuild.exe
get it here https://github.com/kin9puppy/vcbuildFixForNode
Solution 14 - node.js
After a long struggle, I've switched my node architecture to x86 and it worked like a charm.
Solution 15 - node.js
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 :)
Solution 16 - node.js
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.
Solution 17 - node.js
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.