NPM本地版本只安装了Visual Studio 2013。

时间:2021-06-17 00:21:49

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

我已经安装了Visual Studio 2013 Pro安装的Windows系统,以及Python、node和npm的当前版本。

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

我正在尝试安装pg npm包,但是它需要本地构建,并且正在失败:

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]

mso - ascii - font - family: tahoma; mso - hansi - font - family: tahoma; mso - hansi - font - family: tahoma; mso - hansi - font - family: tahoma; mso - hansi - font - family: tahoma ' >项目< / span > < span要构建使用v110构建工具,请安装Visual Studio 2012构建工具。或者,您可以通过选择项目菜单或右击解决方案来升级到当前的Visual Studio工具,然后选择“升级解决方案…”。亚伦(C:\用户\ \ AppData \漫游\ npm \ node_modules \ pg \制造\ 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?

我似乎无法找到Visual Studio 2012的构建工具,我当然更喜欢不需要安装VS2012来满足这一需求。是否有一种方法可以强制安装和构建使用现有的2013编译器/工具,而不需要更改包的代码?

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

我找不到任何一个人用我的Googlefu来描述这个问题和解决方案。

5 个解决方案

#1


17  

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.

我的Windows 8.1(64位)Pro和Visual Studio 2013的安装太干净了(没有以前版本的VS,虽然有些组件是SQL Server 2014)。npm安装命令以类似的错误失败。

So I tried to specify VS version

所以我试着指定VS版本。

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):

它开始正确地使用平台工具集“v120”,但是构建失败了以下错误(注意目标路径中使用的V110):

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.

C:\Program Files (x86)\MSBuild\ Microsoft.Cpp \ v4.0 \ V110 \ Microsoft.Cpp.Platform.targets(44岁,5):错误MSB8020:构建工具v120(平台工具集= v120)不能被发现。要使用v120构建工具,单击项目菜单或右键单击解决方案,然后选择“更新vc++项目…”。使用v120构建工具安装v120。

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

我去了路径c:\Program Files (x86)\MSBuild\ Microsoft.Cpp \ v4.0 \,发现有两个子文件夹:V110 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' }

供参考,版本:VS 2013溢价Python 2.7.8 C:\Windows\ system32系统> npm版本{ http_parser:“1.0”,节点:0.10.29,v8:3.14.5.9,阿瑞斯:1.9.0-DEV,紫外线:0.10.27,zlib:“1.2.3”模块:“11”,openssl:1.0.1h,npm:“1.4.14”}

#2


10  

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

帮助我的是,在运行npm之前,指定环境变量的gi_msvs_version来使用正确的VS,你可以在Control center或控制台设置它,所以2013年是!

set GYP_MSVS_VERSION=2013

and for 2015 you use

而在2015年,你会使用。

set GYP_MSVS_VERSION=2015

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

有了免费VS 2013或2015社区版,这应该是最简单的方式。

PS
I believe for VS 2013 Express you should use

我相信VS 2013的快递你应该使用。

set GYP_MSVS_VERSION=2013e

where e tells npm to use express version

其中e告诉npm使用express版本?

#3


3  

Updated node-gyp to the latest version (1.0.2) by: npm install node-gyp -g

更新的node-gyp到最新版本(1.0.2):npm安装node-gyp -g。

Note that you also have to update the node-gyp that is internally used by node

注意,您还必须更新节点内部使用的节点-gyp。

Now, node-gyp will support your Visual Studio 2013 - you can check in the <npm-cache>/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py, in _CreateVersion method.

现在,nodegyp将支持您的Visual Studio 2013 -您可以在 /node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion中进行检查。py,_CreateVersion方法。

However, the native modules still won't build, giving an error that some include files are missing (ones from Windows SDK, like say winsock2.h). That is because Visual Studio 2013 is bundled with 7.1A SDK as the default. But default Toolset setting is 'v120', which expects the 8.1 SDK (which needs to be installed additionally).

但是,本机模块仍然无法构建,导致一些包含文件丢失的错误(如winsock2.h)。这是因为Visual Studio 2013是与7.1A SDK捆绑在一起的。但是默认的工具集设置是'v120',它期望8.1 SDK(需要另外安装)。

To build with just the stock VS 2013, you need to change what toolset is being selected. You can do that by modifying ~/.node-gyp/common.gypi file (idea taken from here), and changing the toolset to 'v120_xp' instead (which will use the bundled 7.1A SDK):

要构建只使用股票VS 2013,您需要更改所选择的工具集。你可以通过修改~/.node-gyp/common来做到这一点。gypi文件(从这里获取的想法),并将工具集更改为“v120_xp”(将使用绑定的7.1A SDK):

{ ... 'target_defaults': { ... 'configurations': { ... 'Release': { 'conditions': [ ['target_arch=="x64"', { 'msvs_configuration_platform': 'x64', 'msbuild_toolset': 'v120_xp' <--- THIS LINE! }], } } } }

{…“target_defaults”:{…“配置”:{…“Release”:{“条件”:[[endnoteref: 1] ' ', ' ' . ' ' . ' ' . ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' '},}{}

Voila - now the native npm modules will compile with the stock Visual Studio 2013 install!

现在,本机npm模块将使用stock Visual Studio 2013安装编译!

#4


3  

npm config set msvs_version 2013 --global

#5


0  

I was having similar errors with VS2015 but setting the msvs param:

我与VS2015有类似的错误,但是设置msvs param:

npm install --msvs_version=2015

npm安装——msvs_version = 2015

was not solving the problem. I could see that it was looking in the wrong place for the toolset no matter what I did.

没有解决问题。我可以看到,无论我做什么,它都在错误的地方寻找工具。

Long story short I learned that MSBuild is now packaged with Visual Studio and no longer packaged with .NET. Sure enough I had this entry in the PATH variable:

长话短说,我了解到MSBuild现在已经与Visual Studio打包,不再与。net打包。当然,我在PATH变量中有这个项:

C:\Windows\Microsoft.NET\Framework\v4.0.30319;

and consequently the wrong (old) version of MSBuild was being called. I removed this entry and added the following path which is relevant for VS2015:

因此,错误(旧)版本的MSBuild被调用。我删除了这个条目,并添加了与VS2015相关的以下路径:

C:\Program Files (x86)\MSBuild\14.0\Bin\

Problem solved.

问题解决了。

#1


17  

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.

我的Windows 8.1(64位)Pro和Visual Studio 2013的安装太干净了(没有以前版本的VS,虽然有些组件是SQL Server 2014)。npm安装命令以类似的错误失败。

So I tried to specify VS version

所以我试着指定VS版本。

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):

它开始正确地使用平台工具集“v120”,但是构建失败了以下错误(注意目标路径中使用的V110):

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.

C:\Program Files (x86)\MSBuild\ Microsoft.Cpp \ v4.0 \ V110 \ Microsoft.Cpp.Platform.targets(44岁,5):错误MSB8020:构建工具v120(平台工具集= v120)不能被发现。要使用v120构建工具,单击项目菜单或右键单击解决方案,然后选择“更新vc++项目…”。使用v120构建工具安装v120。

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

我去了路径c:\Program Files (x86)\MSBuild\ Microsoft.Cpp \ v4.0 \,发现有两个子文件夹:V110 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' }

供参考,版本:VS 2013溢价Python 2.7.8 C:\Windows\ system32系统> npm版本{ http_parser:“1.0”,节点:0.10.29,v8:3.14.5.9,阿瑞斯:1.9.0-DEV,紫外线:0.10.27,zlib:“1.2.3”模块:“11”,openssl:1.0.1h,npm:“1.4.14”}

#2


10  

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

帮助我的是,在运行npm之前,指定环境变量的gi_msvs_version来使用正确的VS,你可以在Control center或控制台设置它,所以2013年是!

set GYP_MSVS_VERSION=2013

and for 2015 you use

而在2015年,你会使用。

set GYP_MSVS_VERSION=2015

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

有了免费VS 2013或2015社区版,这应该是最简单的方式。

PS
I believe for VS 2013 Express you should use

我相信VS 2013的快递你应该使用。

set GYP_MSVS_VERSION=2013e

where e tells npm to use express version

其中e告诉npm使用express版本?

#3


3  

Updated node-gyp to the latest version (1.0.2) by: npm install node-gyp -g

更新的node-gyp到最新版本(1.0.2):npm安装node-gyp -g。

Note that you also have to update the node-gyp that is internally used by node

注意,您还必须更新节点内部使用的节点-gyp。

Now, node-gyp will support your Visual Studio 2013 - you can check in the <npm-cache>/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py, in _CreateVersion method.

现在,nodegyp将支持您的Visual Studio 2013 -您可以在 /node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion中进行检查。py,_CreateVersion方法。

However, the native modules still won't build, giving an error that some include files are missing (ones from Windows SDK, like say winsock2.h). That is because Visual Studio 2013 is bundled with 7.1A SDK as the default. But default Toolset setting is 'v120', which expects the 8.1 SDK (which needs to be installed additionally).

但是,本机模块仍然无法构建,导致一些包含文件丢失的错误(如winsock2.h)。这是因为Visual Studio 2013是与7.1A SDK捆绑在一起的。但是默认的工具集设置是'v120',它期望8.1 SDK(需要另外安装)。

To build with just the stock VS 2013, you need to change what toolset is being selected. You can do that by modifying ~/.node-gyp/common.gypi file (idea taken from here), and changing the toolset to 'v120_xp' instead (which will use the bundled 7.1A SDK):

要构建只使用股票VS 2013,您需要更改所选择的工具集。你可以通过修改~/.node-gyp/common来做到这一点。gypi文件(从这里获取的想法),并将工具集更改为“v120_xp”(将使用绑定的7.1A SDK):

{ ... 'target_defaults': { ... 'configurations': { ... 'Release': { 'conditions': [ ['target_arch=="x64"', { 'msvs_configuration_platform': 'x64', 'msbuild_toolset': 'v120_xp' <--- THIS LINE! }], } } } }

{…“target_defaults”:{…“配置”:{…“Release”:{“条件”:[[endnoteref: 1] ' ', ' ' . ' ' . ' ' . ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' ' . ' ' ' '},}{}

Voila - now the native npm modules will compile with the stock Visual Studio 2013 install!

现在,本机npm模块将使用stock Visual Studio 2013安装编译!

#4


3  

npm config set msvs_version 2013 --global

#5


0  

I was having similar errors with VS2015 but setting the msvs param:

我与VS2015有类似的错误,但是设置msvs param:

npm install --msvs_version=2015

npm安装——msvs_version = 2015

was not solving the problem. I could see that it was looking in the wrong place for the toolset no matter what I did.

没有解决问题。我可以看到,无论我做什么,它都在错误的地方寻找工具。

Long story short I learned that MSBuild is now packaged with Visual Studio and no longer packaged with .NET. Sure enough I had this entry in the PATH variable:

长话短说,我了解到MSBuild现在已经与Visual Studio打包,不再与。net打包。当然,我在PATH变量中有这个项:

C:\Windows\Microsoft.NET\Framework\v4.0.30319;

and consequently the wrong (old) version of MSBuild was being called. I removed this entry and added the following path which is relevant for VS2015:

因此,错误(旧)版本的MSBuild被调用。我删除了这个条目,并添加了与VS2015相关的以下路径:

C:\Program Files (x86)\MSBuild\14.0\Bin\

Problem solved.

问题解决了。