How to migrate the Yarn from v1 to the latest version

YvonneDev
2 min readNov 11, 2021

The project should have yarn installed.

under the directory of your project:

  1. npm install -g yarn

you can get the latest version like 1.22.17

2. yarn set version berry

this will enable the version 2+

But! When I check after this, my yarn version didn’t change. berry doesn’t work,orz

so I use yarn set version 3.1.0

And the version changed.

And also I tried yarn set version latest

3.rm -fr node_modules

remove modules to set to v3 project

4. run yarn

there is a cache file.

And yarn v3 creates a file .yarnrc.yml includes the yarn path inside.

the NodeLinker will appear in the yarnrc.yml file

5.yarn add .

yarn commit -m “yarn upgrade to v3”

Commit the changes

6. run yarn install to migrate the lockfile

More info check:

The official document

👉Follow me for more useful web development content! love sharing🥰

--

--

YvonneDev

❤️Front-end Web Development self-taught *share what I learned*