package.json:
"scripts": {
"cpFile": cp ../template/index.js /src/view/home/
}
然后我跑:
npm run cpFile fileName.js
我想让它执行
cp ../template/index.js /src/view/home/fileName.js
但它不起作用。
最佳答案
首先,您的命令需要引号
"scripts": {
"cpFile": "cp ../template/index.js /src/view/home/"
}
那么如果你need to pass in args ,您将需要使用 args 分隔符
> npm run cpFile -- fileName.js
>> cp ../template/index.js /src/view/home/ "fileName.js"
可能不是你想要的
您也可以在这里阅读:
> npm help run
编辑
您可能需要传递整个路径才能获得您想要的内容。
"scripts": {
"cpFile": "cp ../template/index.js "
}
然后:
> npm run cpFile -- /src/view/home/fileName.js
关于javascript - 如何加入npm命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43188727/