Watching and running 2 scripts with Node, Concurrently and Typescript causes address in use

580 views Asked by At

I'm trying to use concurrently with nodemon and tsc to have 2 TS scripts be watched, and thus my nodemon server updated when something changes, the index.ts is my router and the queue.ts is a worker. I'm using the following package.json

"dev": "concurrently -k yarn:watch yarn:serve:*",
"watch": "tsc -w",
"serve:index": "nodemon ./build/index.js",
"serve:queue": "nodemon ./build/queue.js"

When running yarn dev I get the following error [serve:*queue] Error: listen EADDRINUSE: address already in use :::3000 even though the queue.js file only contains a console.log

In my index.ts file I'm using express as follows

import express from 'express'

const app = express()
app.use(express.json())

app.listen(3000, () => {
    console.log('Running on 3000...');
    console.log('For the UI, open http://localhost:3000/admin/queues');
});

This is my queue.ts file

console.log('testing');

When the script is not running the port is not in use, I check this by running lsof -i tcp:3000

0

There are 0 answers