2016-07-28 193 views
1

無法使用貓鼬收到錯誤貓鼬連接問題

/Users/kunal/Documents/Node/Project/taskAccomplisher/node_modules/mongodb/lib/server.js:242 
     process.nextTick(function() { throw err; }) 
            ^
MongoError: server 127.0.0.1:27017 received an error {"name":"MongoError","message":"write EPIPE"} 
    at null.<anonymous> (/Users/kunal/Documents/Node/Project/taskAccomplisher/node_modules/mongodb-core/lib/topologies/server.js:213:40) 
    at g (events.js:260:16) 
    at emitTwo (events.js:87:13) 
    at emit (events.js:172:7) 
    at null.<anonymous> (/Users/kunal/Documents/Node/Project/taskAccomplisher/node_modules/mongodb-core/lib/connection/pool.js:119:12) 
    at g (events.js:260:16) 
    at emitTwo (events.js:87:13) 
    at emit (events.js:172:7) 
    at Socket.<anonymous> (/Users/kunal/Documents/Node/Project/taskAccomplisher/node_modules/mongodb-core/lib/connection/connection.js:151:49) 
    at Socket.g (events.js:260:16) 
    at emitOne (events.js:77:13) 
    at Socket.emit (events.js:169:7) 
    at onwriteError (_stream_writable.js:304:10) 
    at onwrite (_stream_writable.js:322:5) 
    at WritableState.onwrite (_stream_writable.js:89:5) 
    at fireErrorCallbacks (net.js:442:13) 

代碼用於連接的MongoDB

var mongoose = require('mongoose') 

mongoose.connect('mongodb://localhost/test') 
var db = mongoose.connection; 
db.on('error', console.error.bind(console, 'connection error:')); 
db.once('open', function() { 
console.log('Running'); 
}); 

我怎樣才能讓使用的是Node.js

MongoDB的連接來連接的MongoDB
+0

你確定Mongo正在運行嗎?當你在終端輸入'mongo'時會發生什麼? – freshnode

回答

1

mongod -repair解決了問題