0d29ff67-9bc6-4d66-a4cb-b34692ba9f46 Skip to content

How To Install Latest Stable Yarn Version

Yarn is a popular package manager for JavaScript projects, offering improved speed and security over npm. If you want to ensure you’re always using the latest stable version of Yarn, you can easily update it with:

Terminal window
yarn set version latest

Step 0: Enable Corepack to Install Yarn

Starting from Node.js 16.10, Yarn is included via Corepack, but it’s disabled by default. You need to enable it before using Yarn:

Terminal window
corepack enable

This command allows you to use Yarn without needing to install it manually via npm.

Step 1: Check Your Current Yarn Version

To verify your current version of Yarn, run:

Terminal window
yarn -v

If this returns an error, make sure Corepack is enabled (see Step 0).

Step 2: Update Yarn to the Latest Stable Version

To update Yarn to the latest stable release within your project, use:

Terminal window
yarn set version latest

This command will:

  1. Fetch the latest stable version of Yarn.
  2. Store it within your project.
  3. Update the .yarn/releases directory.

Step 3: Verify the Update

After the update, confirm that you’re running the latest version by executing:

Terminal window
yarn -v

If it shows the most recent version, your update was successful.

Conclusion

Keeping Yarn updated ensures you benefit from the latest performance improvements, bug fixes, and security patches. Using yarn set version latest is the recommended way to manage updates per project.

Happy coding!