-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐞 yarn set version
on Node.js <18
#5829
Comments
yarn set version
on Node 12 / 14 / 16yarn set version
on Node.js <18
Any workaround so far a part from the version upgrade? We are currently using node.js 14 and 16 |
What I did was:
|
@arcanis - Issue seems fixed today automatically , Did your team publish any fix. ? we were using - RUN yarn set version 3.5.0 in docker file. We would enable corepack too now. |
FROM node:16.16.0 RUN yarn set version 3.6.4 RUN touch yarn.lock works for me |
Yes, the mitigation I mentioned in the post:
In your case you're not using Corepack on those old Node.js images, so our mitigation was sufficient. It's probably the same for most people, but to be careful I preferred to list alternative strategies. |
That's a bug in Yarn v1 and not related to the Node.js version you're using, for example it happens on Node.js v18 as well: $ docker run --rm -it node:18.18.2 bash -c "corepack enable && corepack [email protected] set version 3.6.4 && yarn --version"
4.0.1 @arcanis Seems we need to update https://github.com/yarnpkg/yarn/blob/98036fccb545e4604e9e1ea710dff4e18d7dcc28/src/cli/commands/policies.js#L170 to use the version range provided by the user. |
I am also getting same error, I am using node 20 and yarn classic version 1.22.22 . I resovled it after mentioned "packageManager": "[email protected]" |
I open this thread to cover an issue we noticed regarding Yarn 3.x when used with versions of Node.js lower than 18. It's a little complex, so it's worth opening a thread outlining the problem and the progress on solving it.
What happens?
Running
yarn set version
on Yarn 1.x project will cause it to crash if running with versions of Node.js lower than 18. In particular this happens even when runningyarn set version 3.6.4
, which one would expect to work (since 3.x supports both Node.js 14 and 16).Why does that happen?
As you may know, Yarn 1.x has a different codebase than modern releases. To make
yarn set version
work there, Yarn 1.x actually pulls the latest version of Yarn and forwards theyarn set version
call to it. Unfortunately, it always pulls the latest build - so when we published Yarn 4.0 as stable (which drops support for both Node.js 14 and 16), things broke.Why did we miss it?
It's not a common problem. The installation guide for 3.x releases recommended checking-in the Yarn binary, so running
yarn set version
on CI isn't the most common experience - typical projects already have 3.x installed in their repo, so they don't need to pull the binary at image time.How can you workaround it?
The easiest solution is to not use
yarn set version
with Node.js 12 / 14 / 16. Assuming you cannot upgrade to Node.js 18.x, here are some things you can try:yarnPath
setting in your.yarnrc.yml
.Or, for Node.js 16.x users:
You can enable Corepack and manually add a
"packageManager": "[email protected]"
field to yourpackage.json
.You can also try adding
export YARN_IGNORE_NODE=1
to your CI, which will simply bypass the compatibility check.Or, for Node.js 12.x / 14.x users:
What are we doing to fix that?
Ideally we'd like to "unbreak" it without you having to do anything. We already shipped a mitigation which should help people running Yarn without Corepack, but if you use Corepack things things get quite difficult, and I'm not sure it'll be possible. The best we can do will probably be to release a fix in Yarn 1.x, but older Node.js 12 / 14 / 16 Docker images probably have outdated global Yarn binaries in the first place, so releasing an hotfix won't help.
We're sorry about this problem, and we have plans to avoid them in the future. For now, I suggest to try the listed workarounds and let us know if none of them work for you. I'll update this post as needed.
The text was updated successfully, but these errors were encountered: