Running multiple servers in a single command terminal instance

Viewed 674

I have 3 folders:

enter image description here

Each folder runs a completely different type of server.

api = webpack server, app = angular server and game = gulp server

Each folder requires me to run a different command to run it's server in a separate command instance which is troublesome for my users. They have to have 3 command instances up at the same time which is confusing for them.

Is there a way I can run the following commands within each folder from a single command instance?

api needs to run = npm start

app needs to run = ng serve

game needs to run = gulp watch server

I can't find any resources whatsoever to help in this precise scenerio - which is making me think it's not possible?

1 Answers

I use npm-run-all for a similar usecase.

Install npm-run-all:

npm i npm-run-all

The script block within package.json could look like this:

"scripts": {
    "api": "npm start",
    "app": "ng serve",
    "game": "gulp watch server",
    "all": "npm-run-all --parallel api app game",
},

Note the parameter --parallel.

The command to run:

npm run all
Related