Reputation: 2625
I'm trying to use npm scripts as below:
"scripts": {
"test": "karma start karma.conf.js",
"prestart": "json-server --watch db.json",
"start": "http-server -a localhost -p 8000 -o -c-1"
},
I want to use prestart
(json-server) before running start
(http-server). But I'm only able to run one at a time. If I type npm start
only json-server
runs. Is it possible to run two servers in single command?
Upvotes: 3
Views: 730
Reputation: 23499
You could do something like this:
"scripts": {
"test": "karma start karma.conf.js",
"start-json": "json-server --watch db.json",
"start-http": "http-server -a localhost -p 8000 -o -c-1",
"start": "npm run start-json & npm run start-http"
},
Now npm start
will run start-json
and start-http
concurrently.
Upvotes: 4