Node with mongodb not launching application

0

I'm trying to upload an application in Node with mongoose , (I'm studying, book MEAN home code) and it generates the following error when trying to start the file server.js where I started my application in Node, see below.

Belowismyserver.jsfile.

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 path of the bson.node file is correct, and the file is in the folder.

Below is the connection file with the MongoDB bank.

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);
        });
    });
}
    
asked by anonymous 13.07.2018 / 02:37

0 answers