Npm 如何在package.json中从另一个命令调用一个命令?
假设我在package.json中有这样的脚本Npm 如何在package.json中从另一个命令调用一个命令?,npm,package.json,Npm,Package.json,假设我在package.json中有这样的脚本 "scripts": { "a1": "first command", "a2": "second command", "a3": "third command", } "scripts": { "a1": "
"scripts": {
"a1": "first command",
"a2": "second command",
"a3": "third command",
}
"scripts": {
"a1": "first command",
"a2": "second command",
"a3": "third command && a1 && a2",
}
如果我想在脚本a3中运行脚本a1和a2,我该怎么做?这可能吗?我正在使用
节点版本:v6.9.4
npm版本:4.3.0
我想实现这样的目标
"scripts": {
"a1": "first command",
"a2": "second command",
"a3": "third command",
}
"scripts": {
"a1": "first command",
"a2": "second command",
"a3": "third command && a1 && a2",
}
在脚本中使用
npm run
。例如
“脚本”:{
“a1”:“第一命令”,
“a2”:“第二命令”,
“a3”:“第三个命令和npm运行a1和npm运行a2”,
}
通过CLI运行$npm run a3
将运行第三个命令
(无论是什么),然后是a1
,然后是a2
但是,如果通过CLI运行$npm run a3
仅运行a1
,然后再运行a2
,则:
“脚本”:{
“a1”:“第一命令”,
“a2”:“第二命令”,
“a3”:“npm运行a1和npm运行a2”,
}