suchen

Heim  >  Fragen und Antworten  >  Hauptteil

连接mongodb数据库失败

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)
大家讲道理大家讲道理2754 Tage vor530

Antworte allen(1)Ich werde antworten

  • 大家讲道理

    大家讲道理2017-05-02 09:19:58

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

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

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

    Antwort
    0
  • StornierenAntwort