0
每當我在webstorm運行我index.js
文件,我得到以下錯誤:錯誤在運行的節點js文件
process.nextTick(function() { throw err; })
^
Error: connect ECONNREFUSED 127.0.0.1:27017
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1063:14)
Process finished with exit code 1
這是我index.js
文件:
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/cats');
app.use (bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
var cats = require('./cat_routes.js')(app);
var server = app.listen(3000, function(){
console.log('running at 3000');
});
我通過學習邊一邊有一些教程,但這是一個非常奇怪的錯誤,我不明白。
'mongoose.connect( '的MongoDB://本地主機:27017 /貓');'你能解釋一下這個嗎? –
它只是告訴mongoose通過連接到端口27017上運行的MongoD實例連接到cats數據庫 –