yarn why <package-name>: Find out why a specific package existed.
For example:
ajhsu$ yarn why ajv
yarn why v1.2.1
[1/4] 🤔 Why do we have the module "ajv"...?
[2/4] 🚚 Initialising dependency graph...
[3/4] 🔍 Finding dependency...
[4/4] 🚡 Calculating file sizes...
info Has been hoisted to "ajv"
info Reasons this module exists
- "node-sass#request#har-validator" depends on it
- "webpack" depends on it
info Disk size without dependencies: "380MB"
info Disk size with unique dependencies: "576MB"
info Disk size with transitive dependencies: "612MB"
info Number of shared dependencies: 4
✨ Done in 0.92s.
The Original Post
This document is a quick note of this post: Yarn vs npm: Everything You Need to Know by Tim Severien
Functional Differences
yarn.lock
package.json
could cause version mis-matching, thus, we need a active lock file instead of a positive one(npm-shrinkwrap.json);CLI Differences
Command Equivalents
yarn global add mocha
===npm install mocha -g
yarn add react
===npm install react --save
yarn add react --dev
===npm install react --save-dev
Featured Commands
yarn why <package-name>
: Find out why a specific package existed.For example: