当试图安装一些Node.js的包(sqlite3的,特别是socket.io)使用npm install socket.io
我的Windows 7计算机使用Visual Studio 2012(而不是2010年)我有一些失误,看上去是这样的:
C:\ Program Files文件(x86)的\的MSBuild \ Microsoft.Cpp \ V4.0 \ V110 \ Microsoft.Cpp.Platform.targets(35,5):错误MSB8020:为Visual Studio 2010(平台工具集=“V100的构建工具“)无法找到。 要建立使用V100的构建工具,可以单击项目菜单或右键单击该解决方案,然后选择“更新VC ++项目......”。 安装Visual Studio 2010中使用Visual Studio 2010的构建工具来构建。
为了解决这个问题我的机器上我没有这个命令来安装软件包:
npm install socket.io --msvs_version=2012
我找到了答案在这里与安装的sqlite3遇到的问题时,它与socket.io工作过。
这些可能是更长久的解决方案来解决这个问题:
- 安装Visual Studio 2010
- 更新故宫内部副本节点GYP较新版本的描述在这里和这里 (可能是更好的选择,虽然我没有得到它的工作,但没有尝试过久)
另一种选择是改变,而不是配置每次都指定msvs_version的:
npm config set msvs_version 2012
我有两个Visual Studio速成2013和Visual Studio 2015年社区安装。
我得到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]
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]
原因是最新的Windows Node.js的从网上下载https://nodejs.org包含旧npm
V2(老node-gyp
里面npm
V2)。
我不得不更新Node.js'es内部npm
(也更新node-gyp
):
(open console as an administrator)
cd "C:\Program Files\nodejs"
npm install npm@latest
npm config set msvs_version 2013
现在,它的工作原理(似乎它是一个使用VS 2013暂时)
TL; DR
如果你不想 node-gyp
取决于你安装了Visual Studio的版本(或没有安装VS),安装windows-build-tools
(见下文)。 这将消除这两个错误和升级安装Visual Studio的版本时,应避免未来的问题。
如果你想node-gyp
取决于你安装了Visual Studio的版本,然后npm config set msvs_version 2015
,代替你的版本标签代替2015
。 有效版本标签是: 2015
, 2014
, 2013
, 110
, 100
固定使用windows-build-tools
每节点GYP安装说明 ,你也可以做
npm install --global --production windows-build-tools
的提升命令外壳
这将在严格的Microsoft Visual C ++生成工具(这将在地方的Visual Studio编译使用)所要求的安装node-gyp
,并设置适当msvs_version
刚刚安装的版本。
安装完成后,你应该检查msvs_version
通过设置windows-build-tools
还没有被覆盖。 当执行npm config list
, msvs_version
应该出现下; globalconfig C:\Users\Username\AppData\Roaming\npm\etc\npmrc
; globalconfig C:\Users\Username\AppData\Roaming\npm\etc\npmrc
; 如果没有,通过设定值windows-build-tools
已经覆盖和覆盖值应予以删除。 npm config delete msvs_version
应该删除重写的值和一个由构建工具设置下的全局配置部分应该会出现。
文章来源: npm install for some packages (sqlite3, socket.io) fail with error MSB8020 on Windows 7