npm安装错误:“找不到v120的构建工具(Platform Toolset ='v120'). [英] npm install error: "The build tools for v120 (Platform Toolset = 'v120') cannot be found"

查看:323
本文介绍了npm安装错误:“找不到v120的构建工具(Platform Toolset ='v120').的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行需要重新构建node-gyp的npm install时,引发了以下构建错误:

While running an npm install that required a node-gyp rebuild, the following build error was thrown:

MSB8020:v120的构建工具(平台工具集='v120')不能 被发现.要使用v120构建工具进行构建,请安装v120 构建工具.或者,您可以升级到当前的Visual 通过选择项目"菜单或右键单击Studio工具 解决方案,然后选择重新定位解决方案"

MSB8020: The build tools for v120 (Platform Toolset = 'v120') cannot be found. To build using the v120 build tools, please install v120 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 "Retarget solution"

系统信息

  • Windows 10(x64)
  • Visual Studio 2015
  • 节点v0.12.7
  • npm v2.11.3
  • node-gyp v2.0.1
  • System Information

    • Windows 10 (x64)
    • Visual Studio 2015
    • node v0.12.7
    • npm v2.11.3
    • node-gyp v2.0.1
    • 推荐答案

      tl; dr

      使用msvs_version参数:npm install --msvs_version=2015

      如果msvs_version参数不起作用,则可能是因为您没有安装Visual C ++ 2015构建环境.

      If the msvs_version param doesn't work, it's probably because you don't have a Visual C++ 2015 build environment installed.

      1. 在VS2015安装期间,选择自定义".或者,如果您已经安装了VS2015,请转到Windows的卸载或更改程序">从列表中选择VS2015>单击更改">单击修改"
      2. 选中编程语言">"Visual C ++"下的"Visual C ++ 2015通用工具"选项.
      3. 完成VS2015安装

      选项2:Visual C ++ Build Tools 2015

      作为VS2015的替代方法,您可以安装Microsoft发行的 Visual C ++ Build Tools 2015 :

      1. 在VC ++安装过程中,选择自定义"
      2. 选中"Windows 8.1 SDK"和"Windows 10 SDK"选项
      3. 完成VC ++安装

      使用msvs_version

      现在已经安装了Visual C ++ 2015构建环境,您可以通过msvs_version参数告诉npm使用它:

      Use msvs_version

      Now that a Visual C++ 2015 build environment has been installed, you can tell npm to use it via the msvs_version param:

      1. 打开PowerShell
      2. 使用msvs_version参数:npm install --msvs_version=2015

      配置选项(不是必需的)

      或者,您可以选择将npm添加到npmrc或package.json中,而不是在命令提示符下指定msvs_version参数:

      Config Options (not required)

      Optionally, instead of specifying the msvs_version at the command prompt, you can configure npm to always include the msvs_version param by adding it to your npmrc or package.json:

      npmrc

      打开PowerShell并运行npm config set msvs_version 2015,这会将此参数添加到您的用户npmrc文件中.此后,每次以该用户身份运行npm install时,都会自动包含msvs_version=2015参数

      Open PowerShell and run npm config set msvs_version 2015, which will add this param to your user npmrc file. Henceforth, every time you run npm install, as this user, the msvs_version=2015 param will automatically be included

      (可选)如果计划使用其他Windows帐户登录,并且希望将此设置应用于计算机上的所有帐户,则可以包含全局标志npm config set msvs_version 2015 --global.

      package.json

      修改项目的package.json文件以包括:

      Modify your project's package.json file to include:

      "config": {
        "msvs_version": 2015
      }
      

      此后,每次您运行npm install时,对于该项目,将自动包含msvs_version=2015参数

      Henceforth, every time you run npm install, for this project, the msvs_version=2015 param will automatically be included

      文章修订

      1. 在进一步调查之后,根据Chuck对v120工具集的评论(感谢@ChuckWalbourn),对步骤进行了修订
      2. 添加了配置选项
      3. 添加了VC ++构建工具选项
      4. 已更新了VC ++ Build Tools链接以供正式发布
      1. Steps revised after further investigation inspired by Chuck's comment about the v120 toolset (thanks @ChuckWalbourn)
      2. Added config options
      3. Added VC++ Build Tools option
      4. Updated VC++ Build Tools link for official release

      这篇关于npm安装错误:“找不到v120的构建工具(Platform Toolset ='v120').的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆