【问题标题】:error MSB8007 while downloading dependencies with npm and node使用 npm 和 node 下载依赖项时出现错误 MSB8007
【发布时间】:2015-08-28 20:44:12
【问题描述】:

我正在尝试使用 npm 在我的节点应用程序中安装一些软件包,但我不断收到以下错误。我在 socket.io 和 mongo 上遇到了同样的错误。我经历了许多与此类似的不同错误,并且根据其他线程中的建议安装了很多不同的东西,我真的不知道问题是什么。如果有人对我需要下载/设置什么有任何建议,我将不胜感激。

$ npm install mongodb
npm http GET https://registry.npmjs.org/mongodb
npm http 304 https://registry.npmjs.org/mongodb
npm http GET https://registry.npmjs.org/bson/0.1.9
npm http GET https://registry.npmjs.org/kerberos
npm http 304 https://registry.npmjs.org/bson/0.1.9
npm http 304 https://registry.npmjs.org/kerberos

> kerberos@0.0.2 install c:\Users\Ludicritz\Desktop\Umass-running-app\node_modules\mongodb\node_modules\kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)


c:\Users\Ludicritz\Desktop\Umass-running-app\node_modules\mongodb\node_modules\kerberos>node "c:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bi
n\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild

> bson@0.1.9 install c:\Users\Ludicritz\Desktop\Umass-running-app\node_modules\mongodb\node_modules\bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)


c:\Users\Ludicritz\Desktop\Umass-running-app\node_modules\mongodb\node_modules\bson>node "c:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\.
.\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.InvalidPlatform.Targets(23,7): error MSB8007: The Platform for project 'kerberos.vcxp
roj' is invalid.  Platform='x64'. You may be seeing this message because you are trying to build a project without a solution file, and have specifie
d a non-default Platform that doesn't exist for this project. [c:\Users\Ludicritz\Desktop\Umass-running-app\node_modules\mongodb\node_modules\kerbero
s\build\kerberos.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.InvalidPlatform.Targets(23,7): error MSB8007: The Platform for project 'bson.vcxproj'
 is invalid.  Platform='x64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a
non-default Platform that doesn't exist for this project. [c:\Users\Ludicritz\Desktop\Umass-running-app\node_modules\mongodb\node_modules\bson\build\
bson.vcxproj]
mongodb@1.3.9 node_modules\mongodb
├── kerberos@0.0.2
└── bson@0.1.9

【问题讨论】:

  • 安装 Windows 7 SDK,然后安装 VS C++ Express 2010(适用于您的操作系统的版本)
  • 我都安装了,同样的错误。

标签: node.js msbuild npm


【解决方案1】:

VS C++ Express 2010 32bit 是免费的。如果您安装了 64 位版本的 nodejs,只需将其删除并安装 32 位版本的 node.js

【讨论】:

  • 谢谢你 - 这就是答案!
  • 谢谢,也解决了我的问题~!再次确认答案的正确性
  • 请注意,此时,2010 版本开始出现不兼容问题。不过,值得庆幸的是 2012 版也是免费的,而且很实用。
  • 谢谢,卸载节点 64 位并安装 32 位,它工作。如果官方文档提到这一点会很有用!
【解决方案2】:

我有一个类似的问题,这是我的解决方案。我正在运行 Windows 7 x64。我安装了 x64 版本的 nodejs。我尝试运行安装,这就是我得到的:

起初它想让我把 git 放到我的路径中,我做到了。然后它要我安装 python(不是版本 3.x.x 而是 2.x.x)并将它放在我的路径中,我做到了。然后我安装了 Visual Studio 2010 (c++)。在我完成所有这些之后,我得到了这个错误:

D:\Source\xxxx\grunt-raptr\node_modules\node_modules\libxmljs\build\vendor\libxml\libxml.vcxproj(18,3):错误 MSB4019:导入的项目“D:\Microsoft.未找到 Cpp.Default.props”。确认声明中的路径正确,并且该文件存在于磁盘上。

我在某处读到,如果你在 Visual Studio cmd 中运行它,你可以让它工作,我试过了,我得到了这个错误:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.InvalidPlatform.Targets(23,7):错误 MSB8007:项目“libxml.vcxproj”的平台无效。平台='x64'。您可能会看到此消息,因为您正在尝试构建没有解决方案文件的项目,并且指定了该项目不存在的非默认平台。 [D:\Source\xxxx\node_modules\grunt-raptr\node_modules\libxmljs\build\vendor\libxml\libxml。 vcxproj]

看到这个后,我重新安装了 x32 版本的 nodejs,一切正常。

我希望这对某人有所帮助。

【讨论】:

    【解决方案3】:

    尝试安装节点检查器时:C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.InvalidPlatform.Targets(23,7): error MSB8007: The Platform for project 'bufferutil.vcxproj' is invalid. Platform='x64'

    我的机器:

    • Win 7 64位
    • 节点 0.12.7 64 位
    • Python 2.7 64 位

    我是如何根据网上找到的所有建议修复它的:

    • 卸载所有 VC++ 20xx Redistributables
      • (如果卸载失败,请使用MS FixIt)
    • 安装Microsoft Windows SDK for Windows 7
      • 仅选择Visual C++ Compilers
    • 运行npm install -g node-inspector --python="C:\Python27\python.exe"

    如果还是不行,试试这个:

    • 安装 MS SDK x64 Libraries
    • 在您找到的每个addon.gypi 中添加此行'AdditionalLibraryDirectories': 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib\\x64',
      • C:\nodejs\node_modules\node-gyp\addon.gypi
      • C:\Users\YOU\.node-gyp\0.12.7\deps\npm\node_modules\node-gyp\addon.gypi
      • ?

    addon.gypi:

    ... 'msvs_settings': { 'VCLinkerTool': { 'DelayLoadDLLs': [ 'iojs.exe', 'node.exe' ], # Don't print a linker warning when no imports from either .exe # are used. 'AdditionalOptions': [ '/ignore:4199' ], # THIS LINE HERE 'AdditionalLibraryDirectories': 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib\\x64', }, ...

    祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-03
      • 1970-01-01
      • 1970-01-01
      • 2013-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-07
      相关资源
      最近更新 更多