I'm trying to build a nodeapi for which I am using bunch of libs like express, morgan, nodemon.
Everything was correctly installed with no error in installation
and when I try to use nodemon by updating in package.json file it work for one time then it shooting [is showing? reporting? an] unexpected error
here the error on terminal
> node@1.0.0 start /root/Downloads/node
> nodemon server.js
[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
Server Has Been Started
localhost:3000
events.js:353
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1318:16)
at listenInCluster (net.js:1366:12)
at Server.listen (net.js:1452:7)
at Object.<anonymous> (/root/Downloads/node/server.js:8:8)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1345:8)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '::',
port: 3000
}
[nodemon] app crashed - waiting for file changes before starting...
Here's My app.js looks like
const express = require('express');
const app = express();
const morgan =require('morgan')
const employeeRoutes =require('./api/routes/employee');
const departmentRoutes =require('./api/routes/department');
app.use(morgan('dev'));
// Routes for api
app.use('/employee',employeeRoutes);
app.use('/department',departmentRoutes);
module.exports = app;
And here is my server.js
const http=require('http');
const app =require('./app');
const port =process.env.PORT || 3000;
const server = http.createServer(app);
server.listen(port);
console.log('Server Has Been Started');
console.log('localhost:'+port);
I am using postman to access all request and response.
I did try using npm cache clean --force
but it's not working anymore.