标签:
安装:
连接mongodb:
数据库虽然安装并启动成功了,但我们需要连接数据库后才能使用数据库。怎么才能在 Node.js 中使用 MongoDB 呢?我们使用官方提供的 node-mongodb-native 驱动模块,打开 package.json,在 dependencies 中添加一行:
"mongodb": "1.4.15"
? ~ git:(master) ?cd ./Desktop/blog
? blog git:(master) ?npm install
? ~ git:(master) ? cd ./Desktop/blog ? blog git:(master) ? npm install > kerberos@0.0.4 install /Users/goyoo/Desktop/blog/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.21 install /Users/goyoo/Desktop/blog/node_modules/mongodb/node_modules/bson > (node-gyp rebuild 2> builderror.log) || (exit 0) CXX(target) Release/obj.target/bson/ext/bson.o SOLINK_MODULE(target) Release/bson.node SOLINK_MODULE(target) Release/bson.node: Finished mongodb@1.4.15 node_modules/mongodb ├── readable-stream@2.0.1 (inherits@2.0.1, string_decoder@0.10.31, process-nextick-args@1.0.1, isarray@0.0.1, util-deprecate@1.0.1, core-util-is@1.0.1) ├── kerberos@0.0.4 └── bson@0.2.21 (nan@1.7.0) ? blog git:(master) ?
标签:
原文地址:http://www.cnblogs.com/-yfan/p/4624002.html