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

时间:2014-01-12 00:23:06

标签: c++ visual-studio-2010 node.js visual-studio-2012 msbuild

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
  • 根据this answer
  • 安装VisualStudio 2010环境(已卸载,然后按正确顺序安装)
  • 完全删除VisualStudio 2010并尝试使用VisualStudio 2012,它应该根据Node-gyp wiki
  • 工作
  • 根据this answer
  • 添加了注册表项
  • 根据this answer
  • 使用Windows 7.1 SDK命令提示符进行尝试
  • 根据this answer
  • 在运行npm之前尝试设置VisualStudioVersion
  • 根据this answer
  • 尝试将--msvs_version=2012传递给npm

以上都没有奏效。

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

8 个答案:

答案 0 :(得分:49)

快速解决这个问题的原因是:

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

答案 1 :(得分:16)

最后,微软向VS提供了much better solution

答案 2 :(得分:9)

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

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

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

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

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

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

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

答案 3 :(得分:5)

所以它是2.47am - 想通了。

虽然node-gyp site seems to suggest using Visual Studio 2010 or 2012代替Windows 8.1,但正如Visual Studio Express 2013 for Windows Desktop中所讨论的那样安装this issue

答案 4 :(得分:5)

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

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

正如此forum

所述

答案 5 :(得分:3)

安装人员的快速说明:

  1. Visual Studio 2012(Express)

  2. MSBuild 2012

  3. 问题:

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

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

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

答案 6 :(得分:1)

这与此处描述的问题相同

NPM native builds with only Visual Studio 2013 installed

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

set GYP_MSVS_VERSION=2013

或VS2012

set GYP_MSVS_VERSION=2012 

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

答案 7 :(得分:1)

只要人们再次遇到此问题,就我的情况而言,问题就得到解决了

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

Link for reference

Related question