Reputation: 101
While trying to connect mongodb with Swagger, it is always showing
Error: Cannot find module './config'
var mongoose = require('mongoose'),
sw = require('swagger-node-express'),
config = require('./config'),
db = mongoose.connection;
db.on('error', function() {
console.log('Database connection error'.red);
});
db.on('connecting', function () {
console.log('Database connecting'.cyan);
});
mongoose.connect(config.db_url, {server: {auto_reconnect: true}});
Upvotes: 0
Views: 1341
Reputation: 151
Your config file is not in the root directory It needs to be in the same level with your app.js file
Upvotes: 1