连接mongodb数据库失败
大家讲道理
大家讲道理 2017-05-02 09:17:58
0
1
542

mongodb版本3.2,node安装的mongodb驱动模块版本为1.4.15,顺便问一句Failed to load c++ bson extension, using pure JS version,这个安了bson、node-gyp毫无效果= =

C:\Users\Administrator\blog>node app.js
Failed to load c++ bson extension, using pure JS version
Express server listening on port 3000
C:\Users\Administrator\blog\node_modules\connect-mongo\lib\connect-mongo.js:178
          throw err;
          ^

Error: Error connecting to database: failed to connect to [localhost:27017]
    at null.<anonymous> (C:\Users\Administrator\blog\node_modules\connect-mongo\
node_modules\mongodb\lib\mongodb\connection\server.js:553:25)
    at emitThree (events.js:97:13)
    at emit (events.js:175:7)
    at null.<anonymous> (C:\Users\Administrator\blog\node_modules\connect-mongo\
node_modules\mongodb\lib\mongodb\connection\connection_pool.js:140:15)
    at emitTwo (events.js:87:13)
    at emit (events.js:172:7)
    at Socket.<anonymous> (C:\Users\Administrator\blog\node_modules\connect-mong
o\node_modules\mongodb\lib\mongodb\connection\connection.js:512:10)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at emitErrorNT (net.js:1250:8)
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回复(1)
大家讲道理

搞定了,这个bug可以分两个部分来看,Failed to load c++ bson extension, using pure JS version,这部分需要npm install node-gyp -g 有时死活下不下来有时分分钟下好了;
接着你需要开启mongodb数据库,命令行路径开到mongodb的bin下面
手动设置你要的项目数据库路径 mongod.exe --dbpath c:datablog
然后在项目的package.json里面

"mongodb":"latest",
"express-session":"latest",
"connect-mongo":"latest",
"mongoose":"latest"

把这几个版本安装成最新的,不然还是会报错
再启动大功告成啦~~~

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板