Dung (Donny) Nguyen

Senior Software Engineer

Yarn

Yarn is a JavaScript package manager developed by Facebook, and it’s used to manage project dependencies. It was created as an alternative to npm (Node Package Manager), with a focus on speed, security, and consistency.

🔧 What Yarn Does

Just like npm, Yarn helps you:

🆚 Yarn vs npm

Here’s how Yarn stands out (especially when it was first introduced):

🧪 Common Commands

Action Yarn Command npm Equivalent
Initialize project yarn init npm init
Add a package yarn add package npm install package
Remove a package yarn remove package npm uninstall package
Install all deps yarn npm install
Upgrade a package yarn upgrade npm update

📦 Yarn 2+ (aka Berry)

Yarn introduced Yarn 2 and later versions (codenamed Berry), which brought some big changes:

Yarn 2+ is a bit more opinionated, and not all projects are ready for it out of the box, so some teams still stick to Yarn 1.


If you’re already using npm, you can usually switch to Yarn just by running:

npm install --global yarn