Cannot install node modules that require compilation on Windows 7 x64/VS2012
Solution 1
Try that - will set it globally:
npm config set msvs_version 2012 --global
Solution 2
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
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
just add --msvs_version=2012
node-gyp rebuild --msvs_version=2012
or
node-gyp configure --msvs_version=2012
node-gyp build
Solution 5
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.
Related videos on Youtube
Alex Netkachov
I'm a software developer and programmer with more than 20 years of experience in building software products. I've started my career as junior developer in a small software company in Crimea, Ukraine, building websites for small businesses. Now I'm a Senior Software Developer, building a commodities trading platform, living and working in London, UK. I would be happy to help you if you in need for career advise, want to improve your coding, developing, or teamwork skills. Check out https://alexatnet.com/mentoring for more details.
Updated on January 11, 2020Comments
-
Alex Netkachov over 4 years
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.
-
JohnnyHK over 11 yearsHave you tried running
vcvarsall.bat
instead of trying to set up your environment manually? -
Alex Netkachov over 11 yearsNo success. Still "MSB3411: Could not load the Visual C++ component "VCBuild.exe"."
-
Alex Netkachov over 11 yearsBTW, 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
-
Metalskin over 11 yearsI 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.
-
dkloke over 8 yearsThis 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.
-
CallMeLaNN over 7 years
-
ripper234 almost 7 yearsBest answer: stackoverflow.com/a/31987161/11236
-
roeland about 11 yearsHere is the SDK link: microsoft.com/en-us/download/details.aspx?id=11310
-
sidonaldson over 10 yearsTHANKS!!! MASSIVE KUDOS ps you also have to add Python to your path: stackoverflow.com/questions/4621255/…
-
UnPlan2ned over 10 yearsThe reason for it not finding VCBuild is that it was replaced with MSBuild in 2010, according to codeproject.com/Articles/562386/…
-
Dullroar over 10 yearsAlthough 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!
-
Alex over 10 years@Dullroar superuser.com/questions/372203/… it worked for me with 1 dash shrug
-
rainabba over 10 yearsSee my answer below. vcbuild.exe is required but many environment variables must be set and the node-gyp project doesn't document them.
-
strider over 10 yearsVisual Studio 2012 also comes with 'Developer Command Prompt for VS2012' so you don't have to customize your env PATH variable
-
JD Smith over 10 yearsIf 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!
-
Seiyria about 10 yearsThanks for this; the
npm install
command got it working for me. One dash worked for me as well. -
RaduM about 10 yearsIt should be --msvs-version=2012
-
Benedikt almost 10 yearsThis walkthrough is the best up til now. Nontheless, all this base64 problem is totally unnecessary and annoying!
-
Corin over 9 yearsOh yeah, this is what I needed. Best walk through I've found and it works!
-
Blairg23 over 9 yearsThis worked amazingly with my Windows 7 x64 install! Thanks Microsoft (for being dicks)!
-
Blairg23 over 9 yearsSame answer as above.
-
msulhas over 9 yearsI answered first, look at the date :)
-
Wilbert van de Ridder about 9 yearsWorked for me on Windows 8.1 64bit once I installed python and trying to install
jest-cli
usingnpm install jest-cli --save-dev --msvs_version=2012
-
Rick Rutt about 9 yearsI 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'
-
hansmei about 9 yearsPerfect! Fixed all my problems!
-
Alastair almost 9 yearsExcellent, 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 me
-
user2523784 almost 9 yearsnpm install --msvs_version=2013 did the trick for me - thanks a lot!
-
kta over 8 yearsSometimes 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 :)
-
William over 8 yearsThis should be the recommended answer, worked like a charm on Windows 10
-
adelriosantiago over 8 yearsI 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.
-
Vladimir Vukanac over 8 yearsif this failed for you, check do you have environment variable PYTHON=c:\Python27\python.exe, and stackoverflow.com/a/15937635/2873481
-
Alexander Mills over 8 yearsnpm install -g node-gyp@latest ?
-
Michael K. over 8 yearsThe 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-gyp
-
RPDeshaies over 8 yearsIs 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 -
catalint over 8 yearsupdated answer to include the new readme from node-gyp, thanks @MichaelK.
-
JRulle over 8 yearsI installed VS2015 and ran this command
npm config set msvs_version 2015 --global
which works as well -
Arman Ortega about 8 yearscan you elaborate more on how did you switched to x86 ?
-
CallMeLaNN over 7 years
-
Green over 7 yearsDoesn't work.
error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found.
-
Jon Onstott over 7 yearsSimilarly, installing Microsoft Build Tools 2015 and running
npm config set msvs_version 2015 --global
works -
Ryan Shillington about 7 yearsv3 (npm install --global windows-build-tools) worked great for me on Windows 10.
-
Sean about 7 yearson 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....
-
Xan-Kun Clark-Davis almost 7 yearsYou 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.
-
richardtz almost 7 yearsI'd add +100 if posible ... Thanks a lot
-
hi im vinzent about 6 yearsHow can I undo this configuration? What's the default?
-
Eric about 6 yearsv3 (npm install --global --production windows-build-tools in Administrator shell) still worked for me on Windows 10
-
Michael M almost 6 yearsRunning 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.