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?
This is what worked for me on Windows 10 Pro (x64) with Visual Studio 2015: http://stackoverflow.com/q/32556295/1050784
Simply running npm install --msvs_version=2015 after deleting node_modules fixed this issue for me on Win7 with VS2015. I also did a set GYP_MSVS_VERSION=2015 and closed/opened console, but not sure if that's related.
The task for this ticket is for someone to find a fully working solution for windows 10 and document it. (at the moment there are still different solutions mentioned in this thread)
This might involve getting a VM with windows 10 on it and starting from scratch. Once we know for sure the correct steps, we need to write them into the Readme
@Jayflux I am working on a blog for this currently.
I am going to document the steps I took on my computer and the steps I took on a fresh VM.
I will provide a link when it is done.
Thanks @nullivex you're a hero
@Jayflux Okay here it is. Took all afternoon but I got this working pretty flawlessly on a new installation. I also got my local desktop working.
Here is the blog I put together about the issue: http://www.serverpals.com/blog/building-using-node-gyp-with-visual-studio-express-2015-on-windows-10-pro-x64
It is lengthy but it covers the entire installation process.
I would say the highlights are the following
- Install the latest npm which is
3.3.6at the time of writing - Install Visual Studio Community 2015 Edition. Select Visual C++ during the installation (might not be completely neccessary)
- Set the environment variable GYP_MSVS_VERSION=2015
- Run the command prompt as Administrator
Hopefully this helps someone!
@nullivex could you take a look at my PR? https://github.com/nodejs/node-gyp/pull/766/files
If you're fine with it maybe we can merge that and close this ticket
@Jayflux the pull request looks great! However, I would note that if you use the environment variable GYP_MSVS_VERSION there is no need for npm install --msvs_version=2015 the regular npm install will work fine.
@nullivex added, maybe we can merge and close now (whoever maintains this repo)
According to https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245 the better approach is to run npm config set msvs_version 2015 --global once, instead of defining environment variable. Also, no need to install full blown VS now, just the "Build Tools" which has 2015 compiler, SDKs etc.
@jasonwilliams200OK do you have a link to the Build Tools which need installing for Windows 10? Thanks
@Jayflux, https://www.microsoft.com/en-us/download/details.aspx?id=49512. You may want to wait till Nov 18 for VS2015 Update 1 RTM (TBA in Connect2015 event), which has more C/C++ features and bug fixes. You would be able to download it from http://visualstudio.com/.
You may also want to check last ~20 comments on #629, starting from this Microsoft employee's comment: https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245.
@jasonwilliams200OK's solution worked for me. Thanks
@jasonwilliams200OK would you be able to give some better installation details in bullet point form and maybe we can add them to the README.md then close this issue
Thanks
@Jayflux there you go: //github.com/nodejs/node-gyp/issues/629#issuecomment-158163655.
@jasonwilliams200OK nice Did you want to make a PR changing the documentation (windows bit) with your Q&A you have there? If not i can do it
Then maybe we could close this issue
@Jayflux, IMO, this issue can be close with the solution:
If you have VS2015 installed and you are hitting this error (
MSB8020) orMSB4019, you have somehow a wrong msbuild in yourPATH. To remedy it permanently, add%ProgramFiles(x86)%\MSBuild\14.0\Bin;in case of 64-bit Windows or%ProgramFiles%\MSBuild\14.0\Bin;in 32-bit Windows at the beginning ofPATHunder System Environment variables. For VS2013, replace14.0with12.0and so on.
For the rest of the predicaments, follow this guide: //github.com/nodejs/node-gyp/issues/629#issuecomment-158163655 which will eventually land in the repo's docs after getting some more feedback and reiterating. I will eventually do the pull request.
@nerijusgood, the second issue you are experiencing is MSB3491. Long story short, this is fixed by npm v3 which comes bundle with node.js v5+.
Long story
npm before v3 used to have a command-line option called --dedup. Consider the scenario where you are dependent on package A and B and both A and B are further dependent on package C, then both A and B directories (under your node_modules directory) are having their own nested node_modules directories with package C: node_modules\C. Then C may depend on N-level deep nested dependency chain till the packages which are only using core features of node.js runtime. A rabbit hole. The --dedup switch used to purge out C under A\node_modules and B\node_modules and put C at same level of A and B. This was not the default behavior, which breaks packages with long dependency chains on Windows due to 256 character limit. Even on any operating system npm install .. was producing quite an amount of unnecessarily extra / redundant churn.
With npm 3, it is fixed as now npm install actually does a lot more than what --dedup used to: it flattens all the packages to single hierarchy under node_modules. In case there is a version conflicts, it then keeps both versions by semver rules, i.e. iff major versions are different then keep both, if minor or patch versions are different keep the latest.
For some reason, I cannot update node.js
You can still self-update npm npm install npm@latest -g or [email protected] (that's pacakged with your version of node.js).
For some reason, I cannot update npm as well
Then you might want to look into the package called fenestrate, which was the main source of inspiration behind npm3's flattening behavior.
Had the same problem on Win10. "npm install --msvs_version=2013" helped me. And msvs_version can be set in npm config
why the fugg is microshizzle forcing us to install visual studio to have nodejs work on its OS?