javascript - 为什么我可以将脚本添加到 package.json 中的脚本?
问题描述
我正在尝试将脚本添加到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
,它运行得很好
解决方案
您只是在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"
}
}
推荐阅读
- python - python:在不使用循环的情况下在列表中查找升序/降序元素
- android - Android分页库的loadAfter方法不断调用自身
- python - 从python中的单词列表中查找最长的常用单词序列
- firebase - 将日期对象从 Google 表格转换为 Firebase 时间戳
- java - 具有 OneToOne 映射的两个实体上的 PK 自定义序列生成器引发异常
- docker - 如何在 jenkins 管道中为 docker build 命令指向具体的 Dockerfile?
- c++ - 如何修复 stlsoft.h 中的 VS2017 错误 C1189
- c++ - 当有可用的右值构造函数时,为什么从右值调用类引用构造函数重载?
- sql - 插入父子记录
- node.js - 使用 nodeJs 发布 aws 实例的内存利用率指标