Yarn 3 has issues with post install scripts #5487
Unanswered
danielkaiser80
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have a task to migrate a project from "yarn 1.22" to "yarn berry" ie. "yarn 3".
Unfortunately, the old setup is very cumbersome, and it is forbidden for me to make any breaking changes to this setup.
So the setup uses the node package "postinstall-postinstall": "^2.1.0" which then seems to run every "postinstall" line in every package.json. This is overall nice, but I have to get rid of this behavior for prod builds.
In yarn 1 this was easy, one could basically use a Bash "if" syntax in the "postinstall" scripts, something like this:
"postinstall": "if [ "$SKIP_POSTINSTALL" != 1 ]; then node postinstall-script.js; fi",
Just the new yarn shell seems crippled as it does not like "if".
Also, yarn 1 had an --ignore-scripts flag which one could use with install --production, and then it also skipped such scripts.
Just now, even the "--production" is gone, and I have to fiddle with "yarn workspaces focus -A --production" and this again has no "--ignore-scripts".
Finally, I asked ChatGPT for help, and it said I should do something like this:
"postinstall": "node -e "if (SKIP_POSTINSTALL !== '1') require('./node postinstall-script.js');"", just this also fails, as the environment variable is not transferred correctly.
So is there a way (I mean besides staying with yarn 1 or ditching yarn altogether)?
Beta Was this translation helpful? Give feedback.
All reactions