Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

253
Views
when i use uuid the code unexpected crash, and then works fine?
const express = require('express');
const { uuid } = require('uuidv4');


const app = express();

app.use(express.json())

const projects = [];

app.post('/projects', (req,res)=>{

 const { title, owner } = req.body;
 
  const project = { id: uuid() , title, owner };
  projects.push(project);

  return res.json(project)
})

app.listen(6690, ()=>{
  console.log('Started!๐Ÿ‘Œ');
});

when i execute nodemon:

[nodemon] restarting due to changes...
[nodemon] starting `node src/index.js`
node:events:498
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::6690
    at Server.setupListenHandle [as _listen2] (node:net:1330:16)
    at listenInCluster (node:net:1378:12)
    at Server.listen (node:net:1465:7)
    at Function.listen (C:\Users\Lord\desktop\projetos\bootcamp\backend\node_modules\express\lib\application.js:618:24)
    at Object.<anonymous> (C:\Users\Lord\desktop\projetos\bootcamp\backend\src\index.js:21:5)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1357:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'EADDRINUSE',
  errno: -4091,
  syscall: 'listen',
  address: '::',
  port: 6690
}
[nodemon] app crashed - waiting for file changes before starting...

but if i update one more time, works fine:

[nodemon] restarting due to changes...
[nodemon] starting `node src/index.js`
Started!๐Ÿ‘Œ

if i update one more time, and one more time and... will happen all over again node v16.14.0 nodemon v2.0.14

if i update one more time, and one more time and... will happen all over again node v16.14.0 nodemon v2.0.14

over 4 years ago ยท Santiago Trujillo
1 answers
Answer question

0

From your logs, the first problem that comes to mind is that your nodemon is not existing gracefully when it is stopped or waiting, hence the port already used error. According to this thread it is possible to add in hooks to force nodemon to handle specific events and auto kill processes before it runs again.

over 4 years ago ยท Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!