使用npm和node下载依赖项时出现MSB8007错误

4

我正在尝试使用npm在我的node应用中安装一些包,但我一直收到下面的错误。我使用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(适用于您的操作系统的任何版本)。 - user568109
我已经安装了两个,但是还是出现了相同的错误。 - cspada
3个回答

10

VS C++ Express 2010 32位版本是免费的。如果您已安装了64位版的nodejs,请卸载它并安装32位版本的Node.js。


谢谢 - 那就是答案! - Poni
谢谢,解决了我的问题!对答案的正确性再次确认。 - JK ABC
请注意,目前2010版本开始出现不兼容性问题。但是值得庆幸的是,2012版本也是免费的,并且运行良好。 - Mike 'Pomax' Kamermans
谢谢,我卸载了64位的Node并安装了32位的,现在可以正常工作了。如果官方文档提到这一点会很有用! - Lee Willis

3
我曾经遇到过相似的问题,以下是我的解决方案。我使用的是 Windows 7 x64 操作系统,安装了 x64 版本的 Node.js。我尝试运行安装命令,但出现了以下错误:
起初它要求我将 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): error MSB4019: 导入的项目“D:\Microsoft.Cpp.Default.props”未找到,请确认路径声明正确,且磁盘上存在该文件。 我在某个地方读到,如果在 Visual Studio 命令提示符中运行它,可以让它工作,我尝试了,但出现了以下错误: C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.InvalidPlatform.Targets(23,7): error MSB8007: 项目“libxml.vcxproj”的平台无效。 平台=“x64”。您可能会看到此消息,因为正在尝试构建一个没有解决方案文件的项目,并且指定了此项目不存在的非默认平台。[D:\Source\xxxx\node_modules\grunt-raptr\node_modules\libxmljs\build\vendor\libxml\libxml. vcxproj] 之后我重新安装了 x32 版本的 Node.js,然后一切都正常了。希望这对某些人有所帮助。

0

在尝试安装node-inspector时出现以下错误: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位
  • node 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' ], # 当没有使用来自任何 .exe 的导入时,不要打印链接器警告。 'AdditionalOptions': [ '/ignore:4199' ], # 在此处添加以下行 'AdditionalLibraryDirectories': 'C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib\\x64', }, ...

祝你好运!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接