每次运行需要mongodb
的节点应用时,我都会收到上述错误。我的所有应用程序都像以前一样运行良好,尽管纯JS版本显然速度较慢。
我已经搜索了stackoverflow和github问题页面以尝试解决我的问题,但我尝试过的建议都没有。
我以前运行过mongodb支持的节点应用程序,之前没有任何障碍。但是,我最近一周前使用AppCleaner卸载了Xcode(扫描并删除了剩余的文件),这可能是罪魁祸首。
注意:xcode-select --install
表示已安装
npm update
rm -rf node_modules
,npm cache clean
,npm install
sudo xcode-select -switch /Library/Developer/CommandLineTools
npm install -g node-gyp
后面是位于我应用的node_modules中的mongodb目录内的bson目录中的sudo node-gyp rebuild
。灾难性地失败,这里显示http://pastebin.ca/3011137 sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
这是我的应用程序的package.json
{
"name": "hw1-3",
"version": "0.0.0",
"description": "Homework 1.3",
"main": "app.js",
"dependencies": {
"consolidate": "~0.9.1",
"crypto": "~0.0.3",
"express": "3.x",
"mongodb": "~1.3.11",
"swig": "~0.14.0"
},
"author": "You",
"license": "BSD",
"private": true
}
运行rm -rf node_modules
,npm cache clean
,npm install
后输出npm
npm WARN deprecated swig@0.14.0: v1.0.0 is a complete rewrite of Swig from the ground up. Previous versions are no longer supported
> kerberos@0.0.3 install /Users/prashanthcr/Programming/M101JS/week_1_introduction/homework_1_3/hw1-3/hw1-3/node_modules/mongodb/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/kerberos/lib/kerberos.o
> bson@0.2.5 install /Users/prashanthcr/Programming/M101JS/week_1_introduction/homework_1_3/hw1-3/hw1-3/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bson/ext/bson.o
consolidate@0.9.1 node_modules/consolidate
crypto@0.0.3 node_modules/crypto
swig@0.14.0 node_modules/swig
└── underscore@1.8.3
express@3.20.3 node_modules/express
├── basic-auth@1.0.0
├── merge-descriptors@1.0.0
├── utils-merge@1.0.0
├── cookie-signature@1.0.6
├── methods@1.1.1
├── cookie@0.1.2
├── escape-html@1.0.1
├── fresh@0.2.4
├── range-parser@1.0.2
├── content-type@1.0.1
├── vary@1.0.0
├── parseurl@1.3.0
├── content-disposition@0.5.0
├── commander@2.6.0
├── depd@1.0.1
├── mkdirp@0.5.0 (minimist@0.0.8)
├── proxy-addr@1.0.8 (forwarded@0.1.0, ipaddr.js@1.0.1)
├── debug@2.2.0 (ms@0.7.1)
├── etag@1.5.1 (crc@3.2.1)
├── send@0.12.3 (destroy@1.0.3, ms@0.7.1, mime@1.3.4, etag@1.6.0, on-finished@2.2.1)
└── connect@2.29.2 (pause@0.0.1, response-time@2.3.1, vhost@3.0.0, on-headers@1.0.0, basic-auth-connect@1.0.0, bytes@1.0.0, method-override@2.3.3, serve-static@1.9.3, connect-timeout@1.6.2, qs@2.4.2, cookie-parser@1.3.5, finalhandler@0.3.6, http-errors@1.3.1, morgan@1.5.3, serve-favicon@2.2.1, express-session@1.10.4, body-parser@1.12.4, multiparty@3.3.2, type-is@1.6.2, csurf@1.7.0, compression@1.4.4, errorhandler@1.3.6, serve-index@1.6.4)
mongodb@1.3.23 node_modules/mongodb
├── kerberos@0.0.3
└── bson@0.2.5
在Mac OS X 10.10.3上运行
答案 0 :(得分:2)
您依赖于mongodb
的旧版本,而bson
依赖于mongodb
的旧版本,可能缺少(完全)对节点v0.12 +的支持。
截至本文撰写时,{{1}}的当前版本为2.0.33。请尝试使用它,应正常工作。
在一个不相关的说明中,你依赖于(3.x)的Express版本也是旧的,4.x已经出现了很长一段时间。