按imooc教程node建站一搭的,之前node app.js没问题,可以跑起来。后来就一直报错,下载教程的源码,也是同样的问题。 Error: connect ECONNREFUSED 127.0.0.1:27017 at Object.exports._errnoException (util.js:860:11) at exports._exceptionWithHostPort (util.js:883:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1063:14)
注释了mongoose.connect(‘mongodb://localhost/movie’),就不报错了。但是页面还是一直菊花状态。求高手指教,找了很多资料,有的说是apche进程还在继续,结束进程就可以了,可是没用。说没安装mongodb,试了。有说mongod.lock,找了没这个文件,说明没锁住。实在没辙了~
var express = require('express')
var path = require('path')
var mongoose= require('mongoose')
var _ = require('underscore')
var Movie= require('./models/movie')
var port = process.env.PORT || 3000
var app =express()
var bodyParser= require('body-parser');
app.set('views','./views/pages')
app.set('view engine','jade')
app.use(require('body-parser').urlencoded({extended: true}))
app.use(bodyParser.urlencoded({ extended: true }))
app.use(express.static(path.join(__dirname,'bower_components')))
app.locals.moment = require('moment')
app.listen(port)
console.log('immoc started on port'+port)
// movie为mongodb的一个数据库
mongoose.connect('mongodb://localhost/movie')
@tihumihu mongoose是ODM, 你得装mongodb, 然后运行mongodb https://docs.mongodb.org/manual/tutorial/install-mongodb-on-linux/#id9