Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM native builds with only Visual Studio 2013 installed

I've got a clean install of Windows with Visual Studio 2013 Pro installed, along with current versions of Python, node and npm.

I'm trying to install the pg npm package, but it requires a native build and is failing:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build tools for Visual Studio 2012 (Platform Toolset = 'v110') cannot be found. To build using the v110 build tools, please install Visual Studio 2012 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...". [C:\Users\Aaron\AppData\Roaming\npm\node_modules\pg\build\binding.vcxproj]

I can't seem to find Build tools for Visual Studio 2012 as described, and I'd certainly prefer to not need to install VS2012 just for this one need. Is there a way to force the install and build to use the available 2013 compiler/tools, without changing the code of the package?

I couldn't find anyone describing this specific problem and a solution using my Googlefu.

like image 878
WiredPrairie Avatar asked Nov 18 '13 15:11

WiredPrairie


People also ask

How to integrate npm with Visual Studio?

To add the package. json file, right-click the project in Solution Explorer and choose Add > New Item (or press Ctrl + SHIFT + A). Use the search box to find the npm file, choose the npm Configuration File, use the default name, and click Add. If you don't see the npm Configuration File listed, Node.

How to install npm install in Visual Studio?

For Node. js projects, the easiest way to install npm packages is through the npm package installation window. To access this window, right-click the npm node in the project and select Install New npm Packages. In this window you can search for a package, specify options, and install.


2 Answers

I have too clean install of Windows 8.1 (64bit) Pro with Visual Studio 2013 only (no previous version of VS, although some components came with SQL Server 2014). The npm install command failed with similar error.

So I tried to specify VS version

npm install --msvs_version=2013 <package>

It started correctly using Platform Toolset 'v120' but the build failed with the following error (note the V110 used in the path for targets):

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

I went to the path c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\ and found there two subfolders: V110 and V120.

To correct the path used for targets I had to set environment variable like this:

set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120

Then the package got installed.

For reference, the versions:
VS 2013 Premium
Python 2.7.8
C:\Windows\system32>npm version { http_parser: '1.0', node: '0.10.29', v8: '3.14.5.9', ares: '1.9.0-DEV', uv: '0.10.27', zlib: '1.2.3', modules: '11', openssl: '1.0.1h', npm: '1.4.14' }

like image 165
eXavier Avatar answered Oct 15 '22 07:10

eXavier


What helped me is to specify environment variable GYP_MSVS_VERSION to to use correct VS
you can set it in Control center or in console before running npm, so for 2013 it is

set GYP_MSVS_VERSION=2013

and for 2015 you use

set GYP_MSVS_VERSION=2015

With free VS 2013 or 2015 community edition it should be the easiest way.

PS
I believe for VS 2013 Express you should use

set GYP_MSVS_VERSION=2013e

where e tells npm to use express version

like image 10
v-andrew Avatar answered Oct 15 '22 08:10

v-andrew