I have a project which has html/css/javascript files, and I want to type the command npm start
to run json-server and live-server.
I tried this command: "start": "json-server --watch db.json && live-server"
, but it starts the first command only, and not both.
package.json
{
"name": "testa-npm-live-server",
"version": "1.0.0",
"description": "",
"main": "",
"dependencies": {},
"devDependencies": {
"json-server": "^0.16.1",
"live-server": "^1.2.1"
},
"scripts": {
"start": "json-server --watch db.json && live-server"
},
"author": "",
"license": "ISC"
}
IDE: vscode
Node version: v12.18.1
NPM version: 6.14.5
Use concurrently to run commands in paralell. &&
runs in serial/sequential i.e. second command starts only after first command finishes running.
{
"name": "testa-npm-live-server",
"version": "1.0.0",
"description": "",
"main": "",
"dependencies": {},
"devDependencies": {
"concurrently": "^5.2.0",
"json-server": "^0.16.1",
"live-server": "^1.2.1"
},
"scripts": {
"start": "concurrently \"json-server --watch db.json\" \"live-server\""
},
"author": "",
"license": "ISC"
}
Many Thanks to the community of NodeSchool Campinas for helping :)