[英]Run command script that is not in package.json using yarn
How can I run a script that is not available in package.json
?如何运行
package.json
中不可用的脚本?
Everything works fine if I execute:如果我执行,一切正常:
yarn run build
And my package.json
contains the build script:我的
package.json
包含构建脚本:
{
"scripts": {
"build": "rollup -c"
}
}
But I get an error if I execute directly:但是如果我直接执行,我会得到一个错误:
yarn run rollup -c // ERROR: Command \"rollup -c\" not found
I need to execute commands using the environment variables available to the scripts at runtime of yarn run <script>
.我需要在
yarn run <script>
运行时使用脚本可用的环境变量来执行命令。
Is there any syntax Im missing?我缺少任何语法吗?
When you do yarn run build
it will look for a build
script inside your package.json scripts section.当您执行
yarn run build
时,它会在 package.json 脚本部分中查找build
脚本。
When you are running yarn run rollup -c
it is looking for rollup
which doesn't exist inside your package.json.当您运行
yarn run rollup -c
时,它正在寻找rollup
中不存在的汇总。
If you want to run rollup -c
do it without yarn run
and it should work.如果你想在没有
yarn run
的情况下运行rollup -c
,它应该可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.