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

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

本文关键字:缺少 Microsoft Cpp props Default 节点 Windows 构建 未在      更新时间:2023-10-16

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.

我尝试了以下方法,

  • 将环境变量VCTargetsPath设置为 C:Program Files (x86)MSBuild12.0(错误会相应更改,但 2012 构建工具没有Microsoft.Cpp.Default.props)。
  • 根据此答案安装 VisualStudio 2010 环境(卸载然后按正确顺序安装
  • 完全删除了VisualStudio 2010,并尝试了VisualStudio 2012,它应该根据Node-gyp wiki
  • 工作
  • 根据此答案添加了注册表项
  • 根据此答案尝试使用Windows 7.1 SDK命令提示符
  • 根据此答案尝试在运行npm之前设置VisualStudioVersion
  • 尝试根据此答案将--msvs_version=2012传递给 npm

以上这些都不起作用。

我已经为此花费了很长时间。有没有人有明确的答案?

我的快速解决方案是这样的:

set VCTargetsPath=C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V120
npm install

最后Microsoft为VS提供了更好的解决方案。

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

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

以下说明,以防源出现故障。

  1. 使用"默认安装"选项安装 VC++ 生成工具技术预览版。

    [仅限 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(这代替了每次都npm install [package name] --msvs_version=2015l l 。

所以现在是凌晨 2 点 47 分 - 弄清楚了。

虽然node-gyp网站似乎建议使用Visual Studio 2010或2012,而不是Windows 8.1,安装Visual Studio Express 2013 for Windows Desktop,如本期所述。

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

/property:VCTargetsPath="C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V120

正如本论坛上提到的

给安装人员的快速说明:

  1. Visual Studio 2012 (Express)

  2. MSBuild 2012

与问题:

  1. MSBuild load Microsoft.Cpp.Default.props

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

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

这与此处描述的问题相同

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

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

set GYP_MSVS_VERSION=2013

或用于VS2012

set GYP_MSVS_VERSION=2012 

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

以防万一人们再次遇到此问题,当我执行

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

参考链接

相关问题