45

When trying to install some node.js packages (sqlite3 and socket.io in particular) using npm install socket.io on my Windows 7 machine with Visual Studio 2012 (and not 2010) I had some failures that looked like this:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets(35,5): error MSB8020: The builds tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install Visual Studio 2010 to build using the Visual Studio 2010 build tools.

4 Answers 4

83

To get around this on my machine I did this command to install the package:

npm install socket.io --msvs_version=2012

I found the answer here when having the problem with installing sqlite3 and it worked with socket.io as well.

These might be more permanent solutions to fix the problem:

  1. Install Visual Studio 2010
  2. Updating the npm internal copy to a newer version of node-gyp as described here and here (probably the better option although I didn't get it working but didn't try for too long)
Sign up to request clarification or add additional context in comments.

4 Comments

Yep that worked for me to, though I also had to update the internal node-gyp, this will also work for mongojs and quite a few other issues when using vs2012.
Thanks. I wasted hours trying to figure out what was wrong.
working also with VS 2015: npm install socket.io --msvs_version=2015
Worked for me when installing sqlite3 as well. Cheers!
75

Another option is to change config instead of specifying msvs_version every time:

npm config set msvs_version 2012 

3 Comments

Thank you! I came back here to see if someone might have said this. I got tired of adding the switch every time.
This worked for me when trying to install contextify in VS2013.
I've got VS 2013 installed and so I used this: npm config set msvs_version 2013
2

I have both Visual Studio Express 2013 and Visual Studio Community 2015 installed.

I was getting 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-click the solution, and then selecting "Upgrade Solution...". [G:\work\cinema\node_modules\engine.io\node_modules\bufferutil\build\bufferutil.vcxproj]

The reason was that the latest Node.js for Windows downloaded from https://nodejs.org contains an old npm v2 (and old node-gyp inside that npm v2).

I had to update Node.js'es internal npm (which also updated node-gyp):

(open console as an administrator) cd "C:\Program Files\nodejs" npm install npm@latest npm config set msvs_version 2013 

Now it works (seems that it's using VS 2013 for the time being)

2 Comments

npm config set msvs_version 2015 worked! earlier year versions did not.
I have VS 2015 and Node.js 5.1.1 installed. Setting npm config set msvs_version 2015 did not solve the problem for me. My fix was to create symbolic link for the path the npm install could not find (npm error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Default.props" was not found). Open a command prompt and enter cd C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0 and then mklink /d V110 V140.
0

TL;DR

If you DON'T want node-gyp to depend on your installed version of Visual Studio (or don't have VS installed), install windows-build-tools (see below). This will eliminate both the error and should avoid future issues when upgrading your installed version of Visual Studio.

If you DO want node-gyp to depend on your installed version of Visual Studio, then npm config set msvs_version 2015, substitute your version tag in place of 2015. Valid versions tags are: 2015,2014,2013,110,100


Fixing using windows-build-tools

Per the node-gyp installation instructions, you can also do

npm install --global --production windows-build-tools from an ELEVATED command shell

This will install the strictly the Microsoft Visual C++ Build Tools (this will be used in place of Visual Studio for compilation) required by node-gyp, and appropriately set msvs_version to the version just installed.

After installing, you should check that the msvs_version set by windows-build-tools has not been overridden. When executing npm config list, msvs_version should appear under ; globalconfig C:\Users\Username\AppData\Roaming\npm\etc\npmrc; if it does not, the value set by windows-build-tools has been overridden and the overridden value should be deleted. npm config delete msvs_version should delete the overridden value and the one set by the build tools should appear under the global config section.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.