【问题标题】:Why can I add script to script in package.json? [closed]为什么我可以将脚本添加到 package.json 中的脚本? [关闭]
【发布时间】:2019-09-20 05:34:08
【问题描述】:

我正在尝试将脚本添加到 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,它运行完美

【问题讨论】:

标签: javascript json npm package.json npm-scripts


【解决方案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"
  }
}

【讨论】:

    猜你喜欢
    • 2021-04-21
    • 1970-01-01
    • 2022-01-19
    • 2022-01-20
    • 1970-01-01
    • 2019-07-27
    • 1970-01-01
    • 1970-01-01
    • 2015-02-21
    相关资源
    最近更新 更多