Ao executar este codigo aparece um erro, alguem poderia me ajudar? não consigo achar o erro no codigo abaicho.
const express = require('express');
const mongoose = require('mongoose');
// Iniciando o App
const app = express();
// Iniciando o DB
mongoose.connect(
'mongodb://localhost:27017/nodeapi',
{ useNewUrlParser: true }
);
// Primeira rota
app.get('/',(req, res)=>{
res.send("Hello World");
});
app.listen(3001);
ERRO
events.js:292
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3001
at Server.setupListenHandle [as _listen2] (net.js:1313:16)
at listenInCluster (net.js:1361:12)
at Server.listen (net.js:1447:7)
at Function.listen (/var/www/html/NodeJS/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/var/www/html/NodeJS/server.js:18:5)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1340:8)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 'EADDRINUSE',
errno: 'EADDRINUSE',
syscall: 'listen',
address: '::',
port: 3001
}
[nodemon] app crashed - waiting for file changes before starting...
3001
, pode ser que vc esteja rodando esse script pela 2 vez e não "matou" o que vc rodou antes.app.listen(3003)
ouapp.listen(3010)
e falar o resultado?(node:18136) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.