我正在尝试使用“npm install mongodb”在 Windows 8 机器上为节点 js express 安装 MongoDB,出现以下错误

Posted

技术标签:

【中文标题】我正在尝试使用“npm install mongodb”在 Windows 8 机器上为节点 js express 安装 MongoDB,出现以下错误【英文标题】:I am trying to install MongoDB for a node js express on a Windows 8 machine using 'npm install mongodb', getting following error 【发布时间】:2015-07-28 08:11:04 【问题描述】:

我正在尝试使用“npm install mongodb”在 Windows 8 机器上为节点 js express 安装 MongoDB C:\Users\lisp\Desktop\CRUD>npm install mongodb /

kerberos@0.0.11 安装 C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modules\mongodb-core\node_modules\kerberos (node-gyp 重建 2> builderror.log) || (0号出口)

C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modules\mongodbcor\node_modules\kerberos>if not defined npm_config_node_gyp (node "C:\ProgramFiles\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_module\node-gyp\bin\node-gyp.js" rebuild )  else (rebuild)
npm WARN installMany nopt was bundled with node-pre-gyp@0.6.4, but bundled packa ge wasn't found in unpacked tree
npm WARN installMany npmlog was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany request was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany semver was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany tar was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany tar-pack was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany mkdirp was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany rc was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany rimraf was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
/
> bson-ext@0.1.7 install C:\Users\lisp\Desktop\CRUD\node_modules\mongod\node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext> (node-pre-gyp install --fallback-to-build) || (node-gyp rebuild 2> builderror.log) || (exit 0)


C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" clean )  else (clean)

C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure --fallback-to-build --module=C:\Users\lisp\Desktop\CRUD\node_modules\mongodb node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext\build\Release\bson.node --module_name=bson --module_path=C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext\build\Release )  else (configure --fallback-to-build --module=C:\Users\lisp\Desktop\CRUD\node_modules\mongodb node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext\build\Release\bson.node --module_name=bson --module_path=C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext\build\Release )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT HON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:103:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules npm\node_modules\node-gyp\lib\configure.js:64:11
gyp ERR! stack     at FSReqWrap.oncomplete (evalmachine.anonymous>:95:15)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\Users\\lisp\\Desktop\\CRUD\\node_modules\\mongodb\\node_modules\\mongodb-core\\node_modules\\bson\\node_modules\\bson-ext\\build\\Release\\bson.node" "--module_name=bson" "--module_path=C:\\Users\\lisp\\Desktop\\CRUD\\node_modules\\mongodb\\node_modules\\mongodb-core\\node_modules\\bson\\node_modules\\bson-ext\\build\\Release"
gyp ERR! cwd C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext
gyp ERR! node -v v0.12.2
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd configure --fallb
ack-to-build --module=C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modul
es\mongodb-core\node_modules\bson\node_modules\bson-ext\build\Release\bson.node
--module_name=bson --module_path=C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext\build\Release
' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
node-pre-gyp ERR! stack     at maybeClose (child_process.js:1015:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
node-pre-gyp ERR! System Windows_NT 6.2.9200
node-pre-gyp ERR! command "node" "C:\\Users\\lisp\\Desktop\\CRUD\\node_modules\\
 mongodb\\node_modules\\mongodb-core\\node_modules\\bson\\node_modules\\bson-ext\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp.js" "install" "--fallback-to-build"
 node-pre-gyp ERR! cwd C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext
node-pre-gyp ERR! node -v v0.12.2
node-pre-gyp ERR! node-pre-gyp -v v0.6.4
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd configure --fallback-to-build        
--module=C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext\build\Release\bson.node --module_name=bson --module_path=C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext\build\Release' (1)

C:\Users\lisp\Desktop\CRUD\node_modules\mongodb\node_modules\mongodb-core\node_modules\bson\node_modules\bson-ext>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (rebuild)
npm ERR! Windows_NT 6.2.9200
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "mongodb"
npm ERR! node v0.12.2
npm ERR! npm  v2.7.4
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package mongodb does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer mongoskin@1.4.13 wants mongodb@~1.4

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\lisp\Desktop\CRUD\npm-debug.log

提前谢谢.....:)

【问题讨论】:

【参考方案1】:

安装python 2.7版,而不是3.x:http://www.python.org/

配置windows环境变量:

创建环境PYTHON_PATH=C:\Python\2.7(我用自定义路径,随便用,默认是C:\Python2.7我相信) 创建环境PYTHON=%PYTHON_PATH%\python.exe

将 PYTHON 添加到您现有的路径中: - Path=[...];%PYTHON%;

请注意,您可能还需要其他库,例如 C++,因此您还需要安装 Visual Studio 2010/2013(Express 版本就足够了)

【讨论】:

这次出现错误:“ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' js-bson: Failed to load c++ bson extension , 使用纯 JS 版本”【参考方案2】:
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT HON env variable.

您需要在您的机器上安装 Python 并将 Python 可执行文件设置为环境变量。在 Windows 上构建原生模块需要 Python。

【讨论】:

以上是关于我正在尝试使用“npm install mongodb”在 Windows 8 机器上为节点 js express 安装 MongoDB,出现以下错误的主要内容,如果未能解决你的问题,请参考以下文章

我正在使用 Vue.js 2.0,我正在尝试从“子组件”发出事件

我正在尝试登录 discord 但我收到错误代码

我正在尝试使用硒,但不断收到此错误 [重复]

我正在尝试使用 JavaScript 生成随机颜色代码

我正在尝试使用 Alamofire 框架。如果我尝试导入 Alamofire,我的 xcode 会显示如下错误

我正在尝试使用 ajax 和 symfony 上传文件