我有一个包含html / css / javascript文件的项目,我想输入命令npm start
来运行json-server和live-server。
我尝试了以下命令:"start": "json-server --watch db.json && live-server"
,但它仅启动第一个命令,而不同时启动两个命令。
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
节点版本:v12.18.1
NPM版本:6.14.5
答案 0 :(得分:0)
使用concurrently在 paralell 中运行命令。 &&
以串行/顺序方式运行,即第二条命令仅在第一个命令运行完毕后才开始。
{
"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"
}
非常感谢NodeSchool Campinas社区的帮助:)