这是snipet:
我正在使用快递4。 这是我的代码server.js文件:
// get the required modules
var express = require('express');
mongoose = require('mongoose');
fs = require('fs');
//define the path for mongoDB
var mongoUri = 'mongodb://localhost/noderest';
mongoose.connect(mongoUri);
var db = mongoose.connection;
db.on('error', function(){
//display error
throw new Error('Failed to connect to the DB @' + mongoUri);
});
//create an instance
var app = express();
//Express 4 --V
var env = process.env.NODE_ENV || 'development';
if('development'== env){
app.use(express.bodyParser());
/* app.use(bodyParser.urlencoded());
app.use(bodyParser.json());
*/
};
require('./models/musician.js');
require('./routes.js')(app);
//listen port 2015
app.listen(2015);
console.log("Listening @ http://localhost:2015");
我是(node.js)的新手。如何修复此问题? 感谢。