npm - 调用其他 Yarn 脚本时,纱线脚本失败
问题描述
从 Yarn 脚本调用其他 Yarn 脚本时遇到问题。我想要实现的是yarn develop
在启动几个观察者并运行我的应用程序之前首先调用 TypeScript 和其他一些预处理器的任务。我想使用npm-run-all
(或类似的东西)调用多个目标,因为这将允许我定义单独的目标,我也可以手动运行这些目标,而package.json
.
我制作了一个最小的复制案例,其中包含以下 package.json:
{
"name": "test",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"task:one": "echo one",
"task:two": "echo two",
"run-all": "npm-run-all task:one task:two",
"run-all-yarn": "yarn task:one && yarn task:two"
},
"devDependencies": {
"npm-run-all": "^4.1.5"
}
}
正如预期的那样,调用yarn task:one
会产生. 如果我调用,我会得到一个错误:echo one
yarn task:two
yarn run-all
$-> yarn run-all
yarn run v1.22.10
$ npm-run-all task:one task:two
$ echo one
error Couldn't find the binary echo one
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "task:one" exited with 1.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run-all-yarn
失败(几乎完全正确,没有在第二行执行的命令)相同的错误。
如果我使用 NPM ( npm run run-all
) 而不是 Yarn,则一切都按预期工作:
$-> npm run run-all
> test@1.0.0 run-all /Users/basdalenoord/Projects/52DN/psyflix/test
> npm-run-all task:one task:two
> test@1.0.0 task:one /Users/basdalenoord/Projects/52DN/psyflix/test
> echo one
one
> test@1.0.0 task:two /Users/basdalenoord/Projects/52DN/psyflix/test
> echo two
two
我正在使用我的节点版本从 nvm 提供的 Yarn 版本 1.22.17:~/.nvm/versions/node/v14.18.1/bin/yarn
对于为什么运行单个目标会很好但将它们组合起来对于纱线来说失败,而相同的脚本适用于npm
.
解决方案
推荐阅读
- javascript - Sigma Graph CurvedArrow Edges 仅在悬停时显示
- c - 如何将 uint8_t 数组从 C 发送到 GO
- php - 使用 Yii 命令缓存的 PHP 文件
- html - 无法弄清楚如何使用 Bootstrap 获得 3x4 网格
- c++ - 将正则表达式从 Python 移植到 C++:大括号表达式中的意外字符
- ios - Swift 4.2 如果让 Xcode 11.2 上的 CMTime 失败
- c# - ASP.NET Core 3.0 处理多对多关系记录的正确方法
- java - 来自 Logback 的电子邮件,其变量值从 App.propeties 文件中读取
- c# - 等效于 C# 的 simple-oauth2
- java - if条件怎么写