Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
npm vs yarn command translation cheat sheet
title subtitle author date source
npm vs Yarn Command Translation Cheat Sheet
CLI commands comparison
yarn
February 15, 2020

npm vs Yarn Command Translation Cheat Sheet

npm Yarn
npm init yarn init
npm install yarn install
(N/A) yarn install --flat
(N/A) yarn install --har
(N/A) yarn install --no-lockfile
(N/A) yarn install --pure-lockfile
npm install [package] (N/A)
npm install --save [package] yarn add [package]
npm install --save-dev [package] yarn add [package] --dev
(N/A) yarn add [package] --peer
npm install --save-optional [package] yarn add [package] --optional
npm install --save-exact [package] yarn add [package] --exact
(N/A) yarn add [package] --tilde
npm install --global [package] yarn global add [package]
npm update --global yarn global upgrade
npm rebuild yarn add --force
npm uninstall [package] (N/A)
npm uninstall --save [package] yarn remove [package]
npm uninstall --save-dev [package] yarn remove [package]
npm uninstall --save-optional [package] yarn remove [package]
npm cache clean yarn cache clean
rm -rf node_modules && npm install yarn upgrade
npm version major yarn version --major
npm version minor yarn version --minor
npm version patch yarn version --patch
@skube
Copy link

skube commented Mar 13, 2020

init commands yield slightly different results:

yarn init -y

{
  "name": "example-yarn-init-y",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT"
}

npm init -y

{
  "name": "example--npm-init-y",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

@ptletski
Copy link

ptletski commented Mar 21, 2020

As pointed out by barhoring commented on Feb 13, please correct the npm init and yarn init entries by swapping them. Many thanks.

@jonlabelle
Copy link
Author

jonlabelle commented Mar 31, 2020

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment