yarn set version not working. Can't change from yarn 3.0.0 to yarn 2.0.0
Asked Answered
H

2

9

current yarn version is yarn 3.0.0. Tried changing to yarn 2.0.0 using yarn set version 2.0.0-rc.30. Even after that yarn version still remains at yarn 3.0.0.

Other alternatives I tried: npm uninstall -g yarn then npm install -g yarn. Still yarn version remains at 3.0.0.

Update:

  • managed to get yarn version to 2.0 after deleting yarnrc file from root directory.
Horticulture answered 19/8, 2021 at 7:13 Comment(3)
How exactly did you do this? Got the same issueBendigo
Turns out everything worked when I deleted yarnrc file from root folder.Horticulture
I'd suggest commenting out the yarnPath from the yarnrc.yml rather than deleting it entirely, but helpful.Coagulate
M
5

After some research I found if you have yarn.lock file (even an empty one) yarn set version stops working

Mayramays answered 14/7, 2023 at 9:57 Comment(1)
I got it working by deleting yarn.lock as well as the .yarn directory, removing yarnPath: .yarn/releases/yarn-4.0.2.cjs from the .yarnrc.yml file, running yarn set version stable again, and then adding yarnPath: .yarn/releases/yarn-4.0.2.cjs to the .yarnrc.yml file again.Turtleback
C
1

For me this worked:

$ yarn --version
3.3.1

$ yarn set version berry
➤ YN0000: Retrieving https://repo.yarnpkg.com/3.3.1/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-3.3.1.cjs
➤ YN0000: Done in 0s 299ms

$ yarn --version
3.3.1

$ yarn set version 2.4.2
➤ YN0000: Retrieving https://repo.yarnpkg.com/2.4.2/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-2.4.2.cjs
➤ YN0000: Done in 0s 346ms

$ yarn --version
2.4.2
Caddish answered 19/1, 2023 at 20:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.