运行nodemon server
时,它会记录"Server running successfully on port 3000."
,但它不会记录mongoose.connect
函数中的任何内容。甚至不是错误。
module.exports = {
'database': 'mongodb://root:mypw@LINK-REMOVED/officr',
'port': process.env.PORT || 3000,
"secretKey": "key"
}
var express = require('express');
var bodyparser = require('body-parser');
var morgan = require('morgan');
var config = require ('./config.js')
var mongoose = require('mongoose');
var app = express();
mongoose.connect(config.database, function(err){
if(err){
console.log(err);
}else{
console.log('Connected to database.')
}
});
app.use(bodyparser.urlencoded({ extended: true}));
app.use(bodyparser.json());
app.use(morgan('dev'));
app.get('*', function(req, res){
res.sendFile(__dirname + '/public/index.html');
})
app.listen(config.port, function(err){
if(err){
console.log(err);
}else{
console.log('Server running successfully on port 3000.');
}
})
答案 0 :(得分:1)
Mongolab在工作时被我的防火墙阻挡,它在家里工作得非常好。