Working with YARN

16 Aug, 2022

1 Mins Read

Working in Yarn was a little involved. That is Yarn version 1. One has to play around with Node and NPM to make things setup. With Yarn version 2 and above, this is mostly done by Node and a new utility called corepack.

Now, Yarn does not need to be installed as a global package. Yarn can be enabled for individual projects (individual folders).

The corepack enable is all there is to it.

Open the command prompt and move to the folder, where Yarn is needed. Once there, either initialise an empty Yarn project. That will takecare of everything.

If you are working with an existing project and checked out the code to a folder. Move to this folder from your command prompt. Then run the command corepack enable. That is all.

Now all the yarn commands can work from this folder.

If the project is a Yarn 1 project, it will work with Yarn 1 tools and if it is a Yarn 2 or above project, it will run with the expected Yarn tools.

Related post, Setting different Yarn versions in Ubuntu / Linux