我正在尝试在 package.json 文件中将脚本添加到脚本的手表中。 例如,我得到了:
{
"scripts": {
"delete": "rm -f wwwroot/*.js wwwroot/*.css wwwroot/*.html wwwroot/*.map"
"watch": "npm run delete; parcel watch Client/index.html --out-dir wwwroot"
}
}
然后当我在终端中运行npm run watch
时,它向我抛出此错误:
> projectName@1.0.0 watch C:\Users\username\userProjectName\path\ProjectName
> npm run delete; parcel watch Client/index.html --out-dir wwwroot
npm ERR! missing script: delete;
npm ERR!
npm ERR! Did you mean this?
npm ERR! delete
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\username\AppData\Roaming\npm-cache\_logs\2019-05-01T17_17_44_173Z-debug.lognpm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! projectName@1.0.0 watch: `npm run delete; parcel watch Client/index.html --out-dir wwwroot`
npm ERR! Exit status 1npm ERR!
npm ERR! Failed at the projectName@1.0.0 watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\username\AppData\Roaming\npm-cache\_logs\2019-05-01T17_17_44_193Z-debug.log
但是当我手动运行它时,我的意思是实际进入终端并键入:npm run delete; parcel watch Client/index.html --out-dir wwwroot
,它运行得很好
答案 0 :(得分:1)
在delete
脚本之后,您只是缺少逗号。
{
"scripts": {
"delete": "rm -f wwwroot/*.js wwwroot/*.css wwwroot/*.html wwwroot/*.map",
"watch": "npm run delete; parcel watch Client/index.html --out-dir wwwroot"
}
}