gpt4 book ai didi

node.js - windows 7 使用 npm 安装 mongodb 模块

转载 作者:太空宇宙 更新时间:2023-11-03 23:06:39 25 4
gpt4 key购买 nike

我正在尝试在 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 上构建 native 模块时遇到困难。如果其他人遇到像上面这样的 node-gyp 错误,请尝试以下步骤:

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

引用:node-gyp build error windows x64

关于node.js - windows 7 使用 npm 安装 mongodb 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33071269/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com