C++ 未在 Windows 8.1 上构建的节点包 - 缺少 Microsoft.Cpp.Default.props

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21069699/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 23:28:05  来源:igfitidea点击:

Node packages not building on Windows 8.1 - Missing Microsoft.Cpp.Default.props

c++visual-studio-2010node.jsvisual-studio-2012msbuild

提问by Brendan

NPM packages are not building on Windows 8.1 - failing with following error,

NPM 包未在 Windows 8.1 上构建 - 失败并出现以下错误,

error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

I have tried the following,

我尝试了以下方法,

  • Setting an evironment variable VCTargetsPathto C:\Program Files (x86)\MSBuild\12.0\(The error changes accordingly but there is no Microsoft.Cpp.Default.propswith the 2012 build tools).
  • Installing a VisualStudio 2010 environment (uninstalled then installed in the correct order) according to this answer
  • Completely removed VisualStudio 2010 and tried a VisualStudio 2012 instead, which should work according to the Node-gypwiki
  • Added registry keys according to this answer
  • Tried using the Windows 7.1 SDK command prompt according to this answer
  • Tried setting VisualStudioVersionbefore running npm according to this answer
  • Tried passing --msvs_version=2012to npm according to this answer
  • 将环境变量设置VCTargetsPathC:\Program Files (x86)\MSBuild\12.0\(错误相应更改,但Microsoft.Cpp.Default.props2012 构建工具没有)。
  • 根据此答案安装 VisualStudio 2010 环境(卸载然后按正确顺序安装)
  • 完全删除 VisualStudio 2010 并尝试使用 VisualStudio 2012,它应该根据 Node-gyp维基工作
  • 根据此答案添加了注册表项
  • 根据此答案尝试使用 Windows 7.1 SDK 命令提示符
  • VisualStudioVersion根据此答案在运行 npm 之前尝试设置
  • 尝试--msvs_version=2012根据此答案传递给 npm

None of the above have worked.

以上都没有奏效。

I've spent ages on this already. Does anyone have a definite answer that works?

我已经在这上面花了很长时间。有没有人有一个明确的答案?

采纳答案by Brendan

So it is 2.47am - figured it out.

所以现在是 2.47am - 想通了。

Although the node-gyp site seems to suggest using Visual Studio 2010 or 2012, instead for Windows 8.1, install Visual Studio Express 2013 for Windows Desktopas discussed in this issue.

尽管node-gyp 站点似乎建议使用 Visual Studio 2010 或 2012,但对于 Windows 8.1,请按照本期中的讨论安装Visual Studio Express 2013 for Windows Desktop

回答by AVarabei

The quick fix for me was this:

对我来说,快速修复是这样的:

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

回答by igor

Finally Microsoft is providing much better solutionto VS.

最后,微软为VS提供了更好的解决方案

回答by Antoine

I just wanted to update this question with the latest answer. You now do not need to install Visual Studio.

我只是想用最新的答案更新这个问题。现在不需要安装 Visual Studio。

Source: https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245

来源:https: //github.com/nodejs/node-gyp/issues/629#issuecomment-153196245

Instructions below in case the source goes down.

如果源出现故障,请按照以下说明进行操作。

  1. Install VC++ Build Tools Technical Previewusing the Default Installoption.

    [Windows 7 only] requires .NET Framework 4.5.1

  2. Install Python 2.7, and add it to your PATH: npm config set python python2.7

  3. Launch cmd and run: npm config set msvs_version 2015 --global(this is instead of lnpm install [package name] --msvs_version=2015levery time.)

  1. 使用默认安装选项安装VC++ Build Tools Technical Preview

    [仅限 Windows 7] 需要.NET Framework 4.5.1

  2. 安装Python 2.7,并将其添加到您的 PATH:npm config set python python2.7

  3. 启动 cmd 并运行:( 每次npm config set msvs_version 2015 --global都不是 l npm install [package name] --msvs_version=2015l。)

回答by kromar

Setting the following fixed the problem for me

设置以下内容为我解决了问题

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

As mentioned on this forum

正如在这个论坛上提到的

回答by DrKNa

A quick note for people who installed:

安装人员的快速说明:

  1. Visual Studio 2012 (Express)

  2. MSBuild 2012

  1. Visual Studio 2012(速成版)

  2. MSBuild 2012

with the issue of:

问题是:

  1. MSBuild loads Microsoft.Cpp.Default.props

  2. MSBuild cannot load Microsoft.Cpp.props

  1. MSBuild 加载 Microsoft.Cpp.Default.props

  2. MSBuild 无法加载 Microsoft.Cpp.props

The solution is here: set parameter of MSBuild: /property:VCTargetsPath="C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110"

解决方法在这里:设置MSBuild的参数:/property:VCTargetsPath="C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110"

回答by Cy Pangilinan

Just in case people encounter this issue again, the issue got resolved in my case when I did a

以防万一人们再次遇到这个问题,当我做了一个

npm install -g --production windows-build-tools

npm install -g --production windows-build-tools

Link for reference

链接供参考

Related question

相关问题

回答by mhanney

This is the same issue as described here

这与此处描述的问题相同

NPM native builds with only Visual Studio 2013 installed

仅安装 Visual Studio 2013 的 NPM 本机构建

If you have a version of VS2013 installed set this environment variable before running the npm command:

如果您安装了 VS2013 版本,请在运行 npm 命令之前设置此环境变量:

set GYP_MSVS_VERSION=2013

or for VS2012

或 VS2012

set GYP_MSVS_VERSION=2012 

background reading: https://github.com/Automattic/socket.io/issues/1151

背景阅读:https: //github.com/Automattic/socket.io/issues/1151