-
Notifications
You must be signed in to change notification settings - Fork 147
Open
Description
When I try to run a node code the sub process is not being killed.
This is my npm script:
"scripts": {
"watch": "npx watch --interval=1 'node src/index.js' src"
},This is a minimal version of the app:
const express = require('express');
const PORT = 3000;
const HOST = 'localhost';
const app = express();
// Run
app.listen(PORT, HOST, ()=>{
console.log(`Listening: ${HOST}:${PORT}`);
});This is the error I get:
$ npm run watch
> [email protected] watch
> npx watch --interval=1 'node src/index.js' src
> Watching src
Listening: localhost:3000
# Affter save the file
node:events:492
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use 127.0.0.1:3000
at Server.setupListenHandle [as _listen2] (node:net:1872:16)
at listenInCluster (node:net:1920:12)
at GetAddrInfoReqWrap.doListen [as callback] (node:net:2069:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:8)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1899:8)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '127.0.0.1',
port: 3000
}
Node.js v20.9.0How can I tell the watch command to kill the previous process before starting a new?
siranweb and wenlittleoil
Metadata
Metadata
Assignees
Labels
No labels