Windows 10: The build tools for v120 (Platform Toolset = 'v120') cannot be found.
When installing package via NPM some module had dependency that fired node-gyp rebuild which spawns tons of errors:
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.Cpp.Platform.targets(57,5): error MSB8020: The build t
ools for v120 (Platform Toolset = 'v120') cannot be found. To build using the v120 build tools, please install v120 bui
ld tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-cli
ck the solution, and then selecting "Retarget solution". [C:\Users\nerij\Projects\react-browserify-cli\node_modules\bro
wser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modul
es\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:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "c:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\nerij\Projects\react-browserify-cli\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing [email protected]
npm WARN optional dep failed, continuing [email protected]
This is part of install which gets errors. I fallowed instruction on node-gyp install, however Windows 10 does not allow instal Windows 7 SDKs (I found and installed Windows 10 SDKs, with no efefct). Anyone had same issues?
You need a c++ compiler. And Microsoft happens to be the only place to get a free one for Windows.
If you use node apps that dont need compiled modules. They you can skip this. On Jan 13, 2016 9:12 AM, "hayesmaker" [email protected] wrote:
why the fugg is microshizzle forcing us to install visual studio to have nodejs work on its OS?
— Reply to this email directly or view it on GitHub https://github.com/nodejs/node-gyp/issues/679#issuecomment-171345370.
npm config set msvs_version 2015 -g with visual studio 2015.
worked fine for me (was installing browser-sync globally)
@hayesmaker why the fugg is microshizzle forcing us to install visual studio to have nodejs work on its OS?
@jasonwilliams200OK is this still the case? I thought the Microsoft guys were working on shipping a standalone Visual C++ package that we could use without having to download the whole of VS? Im sure this was in another thread but i can't find it
[C/C++ compiler is required just for those packages that are using native libraries; i.e. few percent of the entire npm world! and this requirement is for all platforms, not only Windows.. see the FFI proposals to node.js which will wave this requirement in future]
@Jayflux, yup we just need VC++ Build Tools 2015 without installing the full-blown VS; that was all over the news, the most famous thread on GitHub: https://github.com/nodejs/node-gyp/issues/629 :smile:
Announcement: http://blogs.msdn.com/b/vcblog/archive/2015/11/02/announcing-visual-c-build-tools-2015-standalone-c-tools-for-build-environments.aspx
Update: https://blogs.msdn.microsoft.com/vcblog/2016/02/16/try-out-the-latest-c-compiler-toolset-without-waiting-for-the-next-update-of-visual-studio/
@jasonwilliams200OK So what about now for us noders@windows after the the update you mentioned? Do we need both nuget and Windows Development Kit or just the later?
@krave1986, nuget package manager is to keep the toolchain in your VS projects. For noders, this is not the requirement, but people (package developers) can do clever things with that option in the mix: Like script a postbuild.js to wget nuget.exe from nuget.org, download the build tools if missing then trigger the msbuild from installed package. Otherwise, if user already had build tools or VS installed, then script will just jump to the build step consuming that installed machinery.
Again, the best thing would be to avoid native compilation on install target through and through. This is possible with FFI, where node.js devs will offload the requirement of providing the native library to consumer (download the dll or dylib or so file from www.example.org or through your system package manager), and the JavaScript will call that native lib through node.js provided foreign function interface (yet to arrive) capability.
@jasonwilliams200OK are you able to update the readme if thats the case? as i think you have the best knowledge of what to do. I think the readme still says install VS
@Jayflux, actually those were published in Microsoft fork by @mousetraps at: https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#prerequisites.
And we have a PR open (https://github.com/nodejs/node-gyp/pull/867) to update the readme (ran into a few snags while adding to CI that we can hopefully address that in the next build tools release. So close! :smiley:)
oh awesome, thanks @mousetraps!
This is a nasty issue :frowning: I am experiencing the same issue reported by the OP. My exact config:
- Windows 10 (64 bit, version 1511 OS Build 10586.218)
- GitHub shell (3.0.17.0)
- nodejs (v5.10.1)
- npm (3.8.3)
- python (2.7.10)
- Visual Studio (Community - 2015 Update 2; including Visual C++ and all sub components)
The npm install I'm running performed several compiles using node-gyp. It was originally failing because node-gyp was defaulting to V110 (which didn't exist on my machine)
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Default.props
I performed the steps @mousetraps outlined here, notably:
- installing the Windows 8.1 SDK
- installing the Windows 10 SDK
- opening a shell, post-install, and running:
npm config set python python2.7
npm config set msvs_version 2015 --global
Just for fun, I've rebooted to make sure things take effect. npm install now fails with this error:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-cli ck the solution, and then selecting "Upgrade Solution...".
Notice how it's using the path for V120, but likely passing msbuild the params for 140. I tried to work around this by doing the following:
- setting environment variable GYP_MSVS_VERSION=2015
- setting PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
- setting VCTargetsPath="C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140"
None of these work. Why is VCTargetsPath being resolved to V120, and not V140?
Glad I didn't give up- I believe I fully understand the issue :smile: Hopefully this helps someone and @mousetraps, you might consider adding this to https://github.com/nodejs/node-gyp/pull/867 (or at least linking to this issue).
The problem
Installing Visual Studio 2013 before or alongside installing Visual Studio 2015 will corrupt the default values used for MSBuild in the Windows registry. Specifically, it corrupts what MSBuild evaluates VCTargetsPath as (incorrectly evaluating it to an older path).
Supporting data
- A fresh install of Windows as documented by @nullivex does not have this issue when Visual Studio 2015 is installed.
- The workaround suggested by @mousetraps does seem to help a decent number of folks. I suspect it helped because they uninstalled/re-installed, which may have fixed the registry.
- Visual Studio is a complicated piece of software and having two side-by-side installs does cause conflicts. This thread on StackOverflow has data for different situations that customers experienced, because of which versions of Visual Studio and probably the order they installed them in.
My work-around
In my case, I had uninstalled Visual Studio 2013, but I never uninstalled/re-installed Visual Studio 2015... I only modified an existing installation.
I was able to force MSBuild to use Visual Studio 2015 by only doing the following:
- Setting the environment variable GYP_MSVS_VERSION=2015, per the documentation
- Running the steps @mousetraps outlined:
- installing SDK for Windows 8.1/Windows 10
- npm config set python python2.7
- npm config set msvs_version 2015 --global
- Setting the environment variable VisualStudioVersion=14.0
- Moving my old MSBuild directory (which didn't get uninstalled) out of the way, like so
mv "C:\Program Files (x86)\MSBuild\12.0" "C:\Program Files (x86)\MSBuild\12.0_OLD"
At this point, it resolves to the correct version... although I experienced the error:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(219,5): error MSB4175: The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v12.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v12.0.dll' or one of its dependencies. The system cannot find the file specified. [C:\Users\Brian\Projects\browser-laptop\node_modules\bloom-filter-cpp\build\bloom-filter-cpp.vcxproj]
For this, I copied the DLL from the MSBuild folder I renamed above. That fixed the issue.
cp "C:\Program Files (x86)\MSBuild\12.0_OLD\Bin\Microsoft.Build.Tasks.v12.0.dll" "C:\Program Files (x86)\MSBuild\14.0\Bin\Microsoft.Build.Tasks.v12.0.dll"
I've tried everything in the workaround except for the last step, since I've never had a MSBuild\12.0 folder; my machine only has MSBuild\14.0 installed.
I keep on experiencing the following error on npm install:
error MSB4019: The imported project "C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Default.props" was not found.
The packages utf-8-validate and bufferutil seem to be the culprits.
As you can see, it looks into the V11 folder, and I only have a v140 folder in my machine.
Noe that this doesn't happen when I run npm install from a Command Prompt with Administrator rights.
But I should be able to run this from a normal PowerShell with posh-git as well. Any ideas?
node-gyp: v3.4.0
Windows 10 and full VS2013 and VS2015 installed (tried on 2 machines).
Setting --msvs_version=2015 and GYP_MSVS_VERSION=2015 does not help.
Only after changing PATH it seems to work:
set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
for using vs2013 it's required the similar :
set PATH=C:\Program Files (x86)\MSBuild\12.0\Bin;%PATH%
how the hell should I understand which VC++ version a package require? Why node-gyp's script can not declare it?! Why node-gyp can find a working VC++ version on machine? that's all simply terrible.
These official guidelines resolved my problem:
https://github.com/nodejs/node-gyp#installation https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#resolving-common-issues
For the summary, Properly install of Python2.7, C++ build tools, then walk through Resolving common issues section on the Microsoft's nodejs guideline should help.
My problem was the MSBuild pointed by the PATH environment variable was not the expected version.
Correct one is "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" (Visual Studio 2015 build tools installed)
msbuild -version
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.
14.0.25420.1
Ran again npm install, and worked like a charm.
The fix for me was to do this in Microsoft Visual Studio 2017: project -> Retarget_solution Platform toolset
and then:
project -> Retarget_solution Windows SDK version
After that, it built with no issues.
https://www.npmjs.com/package/windows-build-tools
npm install --global windows-build-tools
Installs all dependencies as needed
I believe this can be closed now.
In general the recommendation is always to use the same PlatformToolset for addons and for the node engine itself. This means the same compiler should be used to build node and addons.
Older versions of node were built with VS2013, since 6.3.0 I think VS2015 is used.
In general the recommendation is always to use the same PlatformToolset for addons and for the node engine itself. This means the same compiler should be used to build node and addons.
Doesn't this mean in effect we only support building native modules on Windows with one version of Visual Studio?