[英]Node npm error on windows looking for tools version
Im trying to use node and when i go to install the npm packages via 'npm install package.json'我正在尝试使用节点,当我 go 通过“npm install package.json”安装 npm 包时
I am currently using windows 8.1 as my os.我目前使用 windows 8.1 作为我的操作系统。 It began when I started using redis but im not sure if it is because of redis. The error I get is
它开始于我开始使用 redis 但我不确定是不是因为 redis。我得到的错误是
MSBUILD: error MSB4132: The tools version "2.0" is unrecognized.
MSBUILD:错误 MSB4132:无法识别工具版本“2.0”。 Available tools versions are "4.0".
可用的工具版本为“4.0”。
The full console print out is here完整的控制台打印输出在这里
If anyone has come across this error and how to fix it would be greatly appreciated如果有人遇到此错误以及如何解决它,将不胜感激
Provided that you have Nodejs installed, start Windows CMD in admin mode and run the following:如果您安装了 Nodejs,请以管理员模式启动 Windows CMD 并运行以下命令:
npm install --global --production windows-build-tools
and restart your PC afterwards.然后重启你的电脑。
安装 Visual Studio 或 Visual Studio Express 2013。您可以在此处下载它们:http ://www.visualstudio.com/downloads/download-visual-studio-vs
Since most of the answers here are from 2015, thought I provide a fresh guide.由于这里的大部分答案来自 2015 年,我想我提供了一个新的指南。
MS build tools can be installed without installing Visual studio.无需安装 Visual Studio 即可安装 MS 构建工具。 The link below [Check step 3] shows how to install "Visual Studio Installer".
[检查步骤 3] 下面的链接显示了如何安装“Visual Studio 安装程序”。 You can use it to install the required MS build tools.
您可以使用它来安装所需的 MS 构建工具。
https://docs.microsoft.com/en-us/visualstudio/install/install-visual-studio#step-3--- https://docs.microsoft.com/en-us/visualstudio/install/install-visual-studio#step-3---
Following is a screenshot of the workloads I installed以下是我安装的工作负载的屏幕截图
PS: You might need to restart your machine PS:您可能需要重新启动机器
最后,微软提供了更好的解决方案来构建原生 Node.js 包。
As of current you can grab Visual Studio 2013 Community Edition.截至目前,您可以获取 Visual Studio 2013 社区版。 http://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx
http://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx
Installing MS Build Tool 2013 Solved my problem.安装 MS Build Tool 2013 解决了我的问题。
https://www.microsoft.com/en-us/download/details.aspx?id=40760 https://www.microsoft.com/en-us/download/details.aspx?id=40760
Open up a new cmd as administrator and run this command:以管理员身份打开一个新的 cmd 并运行以下命令:
npm install --global --production windows-build-tools
then然后
npm config set msvs_version 2015 --global
close all instances of shell/cmd, reopen a cmd (regular this time, non-administrator) return to your directory where you are trying to run npm install and run it again关闭所有 shell/cmd 实例,重新打开一个 cmd(这次是常规,非管理员)返回到您尝试运行 npm install 的目录并再次运行它
NOTE:笔记:
If you're seeing this in 2019, you may need如果你在 2019 年看到这个,你可能需要
npm config set msvs_version 2017
Please run the below command to fix this issue MSBUILD: error MSB4132: The tools version "2.0" is unrecognized.请运行以下命令修复此问题 MSBUILD:错误 MSB4132:无法识别工具版本“2.0”。 Available tools versions are "4.0".
可用的工具版本是“4.0”。
=> open git bash or CMD after go to project path
=> npm --add-python-to-path='true' --debug install --global windows-build-tools
=> npm config set python "%USERPROFILE%\.windows-build-tools\python27\python.exe"
=> npm install -g windows-build-tools
=> npm run dev
npm install --global windows-build-tools --vs2015
npm install --global windows-build-tools --vs2015
npm install
Works on Windows 11.在 Windows 11 工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.