Trying to set up MEAN server, following this tutorial: https://hackhands.com/mongodb-crud-mvc-way-with-passport-authentication/
Using this git: https://github.com/Hitman666/MEAN_MVC_3rdTutorial
First time I connect to database, it works fine. After CTRL+C and then running "node server" again, I get this error:
c:\mean2\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\base.js:246 throw message; ^ TypeError: Cannot read property 'length' of undefined at processResults (c:\mean2\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.js:1581:31) at c:\mean2\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.js:1619:20 at c:\mean2\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.js:1157:7 at c:\mean2\node_modules\mongoose\node_modules\mongodb\lib\mongodb\db.js:1890:9 at Server.Base._callHandler (c:\mean2\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\base.js:448:41) at c:\mean2\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\server.js:481:18 at MongoReply.parseBody (c:\mean2\node_modules\mongoose\node_modules\mongodb\lib\mongodb\responses\mongo_reply.js:68:5) at null. (c:\mean2\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\server.js:439:20) at emit (events.js:107:17) at null. (c:\mean2\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\connection_pool.js:201:13)
Related blocks of code:
development.js:
var port = 1337;
module.exports = {
port: port,
db: 'mongodb://localhost/todos'
};
mongoose.js:
var config = require('./config'),
mongoose = require('mongoose');
module.exports = function() {
var db = mongoose.connect(config.db);
return db;
};
config.js:
module.exports = require('./env/' + process.env.NODE_ENV + '.js');
server.js:
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var config = require('./config/config'),
mongoose = require('./config/mongoose'),
express = require('./config/express'),
var db = mongoose(),
app = express();
app.listen(config.port);
module.exports = app;
console.log(process.env.NODE_ENV + ' server running at http://localhost:' + config.port);
Also of note, if I db.dropDatabase() then "node server" again, it works fine.
killall node
and try again? – Florian Wendelborn