npm vs Yarn Commands Cheat Sheet

William Le

Here’s a cheat sheet you can use as a handy reference for npm & Yarn.

There’s a lot of similarities between npm and Yarn. As the newer technology Yarn (released 2016) drew a lot of inspiration from npm (2010).

On the flip-side, their similarities can lead to confusion and silly mistakes if you find yourself using both package managers. Hopefully this cheat sheet will serve as a handy reference! 🐊

npm vs Yarn

Install dependenciesnpm installyarn
Install packagenpm install [package]yarn add [package]
Install dev packagenpm install --save-dev [package]yarn add --dev [package]
Uninstall packagenpm uninstall [package]yarn remove [package]
Uninstall dev packagenpm uninstall --save-dev [package]yarn remove [package]
Updatenpm updateyarn upgrade
Update packagenpm update [package]yarn upgrade [package]
Global install packagenpm install --global [package]yarn global add [package]
Global uninstall packagenpm uninstall --global [package]yarn global remove [package]
Recommended Node.js video course

Things that Haven’t Changed

There are some commands that Yarn decided not to change. Here’s a quick breakdown:

npm inityarn init
npm runyarn run
npm testyarn test
npm login (and logout)yarn login (and logout)
npm linkyarn link
npm publishyarn publish
npm cache cleanyarn cache clean
  Tweet It

🕵 Search Results

🔎 Searching...

Sponsored by #native_company# — Learn More
#native_title# #native_desc#