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

问题描述 投票:53回答:8

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)\MSBuild\12.0\(错误会相应更改,但2012年的构建工具没有Microsoft.Cpp.Default.props)。
  • 根据qazxsw poi安装Visual Studio 2010环境(以正确的顺序卸载然后安装)
  • 完全删除VisualStudio 2010并尝试使用VisualStudio 2012,它应该根据this answer工作
  • 根据Node-gyp wiki添加了注册表项
  • 根据this answer使用Windows 7.1 SDK命令提示符进行尝试
  • 根据this answer尝试在运行npm之前设置VisualStudioVersion
  • 根据this answer尝试将--msvs_version=2012传递给npm

以上都没有奏效。

我已经花了很多年的时间。有没有人有明确的答案有效?

c++ visual-studio-2010 node.js visual-studio-2012 msbuild
8个回答
48
投票

我的快速解决方法是:

this answer

16
投票

最后,微软正在向VS提供set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120 npm install


9
投票

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

资料来源:much better solution

如果信号源发生故障,请遵循以下说明。

  1. 使用“默认安装”选项安装https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245。 [仅限Windows 7]需要VC++ Build Tools Technical Preview
  2. 安装.NET Framework 4.5.1,并将其添加到您的路径:Python 2.7
  3. 启动cmd并运行:npm config set python python2.7(这不是每次都是lnpm config set msvs_version 2015 --global。)

5
投票

所以它是2.47am - 想通了。

虽然npm install [package name] --msvs_version=2015l,而不是Windows 8.1,安装node-gyp site seems to suggest using Visual Studio 2010 or 2012讨论Visual Studio Express 2013 for Windows Desktop


5
投票

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

this issue

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


3
投票

安装人员的快速说明:

  1. Visual Studio 2012(快递)
  2. MSBuild 2012

问题是:

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

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


1
投票

这与此处描述的问题相同

forum

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

NPM native builds with only Visual Studio 2013 installed

或者VS2012

set GYP_MSVS_VERSION=2013

背景阅读:set GYP_MSVS_VERSION=2012


1
投票

为了防止人们再次遇到这个问题,当我做了一个问题时,问题就解决了

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

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

Link for reference

© www.soinside.com 2019 - 2024. All rights reserved.