當我運行node app.js
,我得到以下錯誤:錯誤:無法連接到[本地主機:27017]
Failed to load c++ bson extension, using pure JS version
Express server listening on port 3000
events.js:85
throw er; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
at null.<anonymous> (/Users/me/development/node_modules/mongodb/lib/mongodb/connection/server.js:553:74)
at emit (events.js:118:17)
at null.<anonymous> (/Users/me/development/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
at emit (events.js:110:17)
at Socket.<anonymous> (/Users/me/developmen/node_modules/mongodb/lib/mongodb/connection/connection.js:512:10)
at Socket.emit (events.js:107:17)
at net.js:451:14
at process._tickCallback (node.js:355:11)
我不知道這是否是本地主機問題,還是到MongoDB的連接問題。我試着尋找類似的問題SO和Github,但它沒有幫助我。
'mongod'是否正在運行?如果是這樣,你應該可以從命令行用'mongo'進入mongo shell – azium
@azium如何檢查'mongod'是否正在運行?以防萬一您有與我不同的檢查方式。 – maregor
只需在命令行鍵入'mongo'。應該看到類似這樣的內容:http://i.imgur.com/Elu8Zjp.png – azium