我将我们的项目 yarn 从 v1.22 升级到 v3.1.1。我们使用工作区,所以我有那个插件。一切似乎都很好;其他脚本可以工作,但是在尝试使用 shell 命令时出现此错误:
> yarn run start
command not found: if
command not found: then
command not found: fi
这是我们 package.json 中的脚本:
"scripts": {
"build": "yarn run --top-level tsc",
"lint": "yarn run --top-level eslint './src/**/*.{ts,js}'",
"start": "if [[ $BLAH ]]; then yarn generateEnvFile; fi && yarn copyEnterpriseWsdl && node dist/index.js",
"generateEnvFile": "node blah.js > .env",
"copyEnterpriseWsdl": "cp blah blah"
}
我最终得到了更多的解决方法,而不是弄清楚问题是什么:
"scripts": {
// ...
"start": "/bin/sh ./start-prod.sh"
}
那个脚本有我真正需要运行的地方。 🤷u200d♂️
如果你仍然想保持代码内联,你可以使用以下方法:
"scripts": {
// ...
"start": "/bin/sh -c 'if [[ $BLAH ]]; then yarn generateEnvFile; fi' && yarn copyEnterpriseWsdl && node dist/index.js"
}