First, the first command to understand
npm install
=== yarn
—— install is the default behavior.
npm install taco --save
=== yarn add taco
—— The taco package is immediately saved in package.json.
npm uninstall taco --save
=== yarn remove taco
In npm, you can use the npm config set save true
setting— -save
the default behavior, but this is not obvious to most developers. In yarn, adding and removing behaviors in package.json is the default.
npm install taco --save-dev
=== yarn add taco --dev
npm update --save
=== yarn upgrade
update vs upgrade, praise! Upgrade is the actual thing! When the version number is increased, it is upgrade!
Note: npm update --save seems to have a problem in version 3.11.
npm install taco@latest --save
=== yarn add taco
npm install taco --global
=== yarn global add taco
—— As always, please use the global mark with caution.
2. Known commands
The package is the same as on the npm registry. Roughly speaking, Yarn is just a new installation tool, and the npm structure and registry are the same.
npm init
=== yarn init
npm link
=== yarn link
npm outdated
=== yarn outdated
npm publish
=== yarn publish
npm run
=== yarn run
npm cache clean
=== yarn cache clean
npm login
=== yarn login
(logout same)
npm test
=== yarn test
3. Yarn's unique commands
I skipped some content that reminded us not to use eg yarn clean
.
yarn licenses ls
—— Allows you to check the dependent license information.
yarn licenses generate
—— Automatically create a dependency disclaimer license.
yarn why taco
—— Check why taco is installed and list in detail other packages that depend on it (thanks Olivier Combe).
Emojis
Automatically implement shrinkwrap through yarn lockfile
Safety-centric design
Fourth, Npm's unique commands
npm xmas
=== NO EQUIVALENT
npm visnup
=== NO EQUIVALENT