Understanding Yarn Version Management: Comparing yarn set version berry
and corepack prepare yarn@stable --activate
#5394
Unanswered
wojtekKrol
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
-
Previously, I had Yarn
v1.22.x
installed. I completely removed it by runningrm -rf ~/.yarn
and removing it from nvm node versions. Then, I followed the installation guide from https://yarnpkg.com/getting-started/install. When I rancorepack prepare yarn@stable --activate
, it installed Yarnv3.5.0
globally in$HOME/.nvm/versions/node/v18.16.0/bin/yarn
.By using
yarn set version berry
, Yarn will use the locally installed version of Yarn within the context of the current project. Whereas,corepack prepare yarn@stable --activate
prepares Corepack to use the latest stable version of Yarn at the package manager level. Both of these commands achieve a similar result, but they work at different levels of the project.To clarify,
yarn set version berry
sets the Yarn version to "berry" within the project's context. It uses the version specified in$PROJECT_DIR/.yarn/releases/yarn-3.5.0.cjs,
as defined inpackage.json
using the"packageManager": "yarn@3.5.0"
configuration - I suppose?Now, I am wondering if I need to run yarn set version berry in every new project if I have the latest version of Yarn installed globally?
Because I think that I don't have to.
If I have the latest version of Yarn installed globally, then I do not need to run yarn set version berry to switch to Yarn's Berry. Berry is simply a different version of Yarn with significant changes to the way packages are managed. I don't have any project with yarn at all so it won't affect anything.
Beta Was this translation helpful? Give feedback.
All reactions