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)
搞定了,這個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裡面
把這幾個版本安裝成最新的,不然還是會報錯
再啟動大功告成啦~~~