45

Im trying to use node and when i go to install the npm packages via 'npm install package.json'
I am currently using windows 8.1 as my os. It began when I started using redis but im not sure if it is because of redis. The error I get is

MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0".

The full console print out is here

If anyone has come across this error and how to fix it would be greatly appreciated

Dennington-bear
  • 1,732
  • 4
  • 18
  • 44

10 Answers10

75

Provided that you have Nodejs installed, start Windows CMD in admin mode and run the following:

npm install --global --production windows-build-tools

and restart your PC afterwards.

sinetemba
  • 33
  • 8
Tomas Randus
  • 2,127
  • 4
  • 29
  • 38
  • 2
    Helped! Tried on Windows 10 without Visual Studio installed. – liquide Feb 20 '17 at 17:25
  • 1
    This solved it for me without having to install VS 2013 (or any other version) – joshcomley Jul 12 '17 at 08:04
  • 6
    Works, but ATTENTION: After installation, the system reboots **immediately without any confirmation!** That's not acceptable and can be very dangerous, depending what you're doing/what's running on the machine... – Lion Feb 17 '18 at 11:04
  • 1
    This worked, without doing anything related to Visual Studio :) – Khateeb321 Dec 11 '18 at 12:25
  • January'19: This worked but then I kept having the error "MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0". Installing version 4 of the window-build-tools solved my problem. More details here: https://github.com/felixrieseberg/windows-build-tools/issues/152 This should be solved eventually, though. – elbecita Jan 16 '19 at 15:07
  • Worked but needed restart. – Tirath Apr 30 '19 at 06:46
  • 7
    This did not work for me. Installer just freezes. Also tried getting it @ version 4, in this case a bunch of URLs could not be resolved and it crashed. I ended up installing Windows 10 SDK instead. – Victor Zakharov Jun 09 '21 at 14:27
  • you can download MS build tools separately too. here is the link https://www.microsoft.com/en-us/download/confirmation.aspx?id=40760 Reference: https://github.com/chjj/pty.js/issues/60 – Ali Khan Feb 21 '22 at 13:26
9

Install Visual Studio or Visual Studio Express 2013. You can download them here: http://www.visualstudio.com/downloads/download-visual-studio-vs

Gergo Erdosi
  • 40,904
  • 21
  • 118
  • 94
  • 15
    Any way to get msbuild without the +6GB IDE? –  Jul 08 '15 at 02:29
  • 9
    Instead of full VS 2013, you can install just MS Build Tools, but you need to find the right version. Another solution is to tell `npm` to use another version of the compiler that you already have installed: `npm install package.json --msvs_version=2013` – quasoft Jul 25 '15 at 15:06
  • 1
    hero of the month: @quasoft `msvs_version` is really undocumented, but at the same time is a solution for a so vast number of compile problems It's also permanent using `npm config set msvs_version 2013` (or 2015) – Valerio Aug 13 '15 at 10:49
  • 2
    @GergoErdosi I have installed MS BuilD Tool 2013, but it has MSBUILD of version "12.0". Where I can download MSBUILD v "2.0"? – VB_ Sep 04 '15 at 13:50
  • 1
    Why do you suggest installing full huge VS? MS offers all build tools as standalone downloads. What's the point to install VS then? Can't we use just those MSBuild tools alone? – Green Nov 16 '16 at 13:20
  • This worked for me `choco install microsoft-build-tools --version 14.0.25420.1` However, you will need chocolatey installed. – Ryan Taylor Jun 01 '18 at 00:34
9

Since most of the answers here are from 2015, thought I provide a fresh guide.

MS build tools can be installed without installing Visual studio. The link below [Check step 3] shows how to install "Visual Studio Installer". You can use it to install the required MS build tools.

https://learn.microsoft.com/en-us/visualstudio/install/install-visual-studio#step-3---

Following is a screenshot of the workloads I installed

enter image description here

P.S: You might need to restart your machine

Abdelrahman Shoman
  • 2,882
  • 7
  • 36
  • 61
4

Finally Microsoft is providing much better solution to build native Node.js packages.

igor
  • 5,351
  • 2
  • 26
  • 22
2

As of current you can grab Visual Studio 2013 Community Edition. http://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx

Jesse
  • 1,846
  • 2
  • 22
  • 32
  • ya I got it fixed around the time I was doing it. There was a file needed from the visual studio setup that corrected itself when i installed it – Dennington-bear Feb 26 '15 at 15:47
2

Open up a new cmd as administrator and run this command:

npm install --global --production windows-build-tools

then

npm config set msvs_version 2015 --global

close all instances of shell/cmd, reopen a cmd (regular this time, non-administrator) return to your directory where you are trying to run npm install and run it again

NOTE:

If you're seeing this in 2019, you may need

npm config set msvs_version 2017
Abolfazl Roshanzamir
  • 12,730
  • 5
  • 63
  • 79
1

enter image description here

These commands worked for me.

 & npm --add-python-to-path='true' --debug install --global windows-build-tools
 & npm config set python "%USERPROFILE%\.windows-build-tools\python27\python.exe"
 & npm install -g windows-build-tools
 & npm install.
 & npm start.

Solution found here

0

Installing MS Build Tool 2013 Solved my problem.

https://www.microsoft.com/en-us/download/details.aspx?id=40760

Abhishek Sengupta
  • 2,938
  • 1
  • 28
  • 35
0

Please run the below command to fix this issue MSBUILD: error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "4.0".

=> open git bash or CMD after go to project path 
=> npm --add-python-to-path='true' --debug install --global windows-build-tools
=> npm config set python "%USERPROFILE%\.windows-build-tools\python27\python.exe"
=> npm install -g windows-build-tools
=> npm run dev
Chirag Prajapati
  • 529
  • 6
  • 10
0
  1. Install all you need Node.js, VSCode, Python 2.7, etc.
  2. Run as admin VSCode.
  3. In VSCode bash write npm install --global windows-build-tools --vs2015
  4. npm install

Works on Windows 11.