繁体   English   中英

windows 7用npm安装mongodb模块

[英]windows 7 install mongodb module with npm

我试图在我的Windows 7上安装mongodb。我安装了Windows 7 SDK,全局安装了node-gyp。

我安装了express-generator,并生成了一个测试应用程序。 当我试图运行此命令时:

"npm install mongodb --save" 

我得到这个错误:

"gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 2148734720"

日志:

> kerberos@0.0.15 install c:\node\test1\node_modules\mongodb\node_modules\mongod
b-core\node_modules\kerberos
> (node-gyp rebuild) || (exit 0)
c:\node\test1\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerber
os>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_module
s\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )
else (node  rebuild )
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` fail
ed with exit code: 2148734720
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\
npm\node_modules\node-gyp\lib\build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:200:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd c:\node\test1\node_modules\mongodb\node_modules\mongodb-core\node_m
odules\kerberos
gyp ERR! node -v v4.1.2
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
mongodb@2.0.45 node_modules\mongodb
├── es6-promise@2.1.1
├── readable-stream@1.0.31 (string_decoder@0.10.31, core-util-is@1.0.1, isarray@
0.0.1, inherits@2.0.1)
└── mongodb-core@1.2.14 (bson@0.4.16, kerberos@0.0.15)

真的在寻求帮助。 谢谢

似乎很多人在Windows上构建本机模块时遇到了麻烦。 如果其他人遇到如上所述的node-gyp错误,请尝试以下步骤:

  • 确保安装了最新版本的nodenpm
  • 确保安装了Python 2。
  • 确保已安装MSVC构建工具。 最简单的方法是安装Visual Studio(使用C ++组件)
  • 清除NPM缓存(从项目文件夹中删除node_modules
  • 运行npm config set msvs_version 2013 --global
  • 运行npm install

参考: node-gyp构建错误windows x64

错误代码实际上是代码0x80131700(2148734720到十六进制)。 要修复它,只需像这样启动msbuild.exe:

MsBuild [SLN的完整路径] / nologo / p:配置=发布;平台= [x64或x86]

这会引发错误。 对我来说它说安装了错误的.NET框架,它问我现在是否要安装它。 我选择了是,安装后工作正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM