0
I’m trying to raise an application in Node with mongoose
, (I am studying, MEAN book code house) and generates me the following error while trying to start the file server.js
where I start my application on Node, see below.
Below is my server.js file.
var http = require('http');
var app = require('./config/express')();
require('./config/database.js')('mongodb://localhost/contatooh');
http.createServer(app).listen(app.get('port'),function(){
console.log('Express server executando na porta ' + app.get('port'));
});
NOTE: the file path bson.node
is correct, and the file is existing in the folder.
Below is the connection file with the bank Mongodb.
var mongoose = require('mongoose');
module.exports = function(uri){
mongoose.connect(uri);
mongoose.connection.on('connected', function(){
console.log('Mongoose ! conectado em '+uri);
});
mongoose.connection.on('disconnected', function(){
console.log('Mongoose ! Desconectado de '+uri);
});
mongoose.connection.on('error', function(erro){
console.log('Mongoose ! erro na conecxão '+erro);
});
process.on('SIGINT', function(){
mongoose.connection.close(function(){
console.log('Mongoose ! Desconectado pelo término da aplicação');
process.exit(0);
});
});
}
Hello, blz? do you have this code on github? ...I find it strange that line 5: require('. /config/database.js')('mongodb://localhost/contactooh');
– Valter Neto
Oops ! blz and vc ? Thanks for the feedback, I shared it on github so you can have a look. Link: https://github.com/LucasPiresDev/mean_stack vlw !!!
– Lucas Pires