Command Line Summary of yarn and npm, yarnnpm command line
1. commands to be understood first
npm install
===yarn
-- Install is the default action.
npm install taco --save
===yarn add taco
-- The taco package is immediately saved to package. json.
npm uninstall taco --save
===yarn remove taco
In npm, you can usenpm config set save true
Settings--save
Is the default action, but this is not obvious to most developers. In yarn, adding (add) or removing (remove) in package. json is the default action.
npm install taco --save-dev
===yarn add taco --dev
npm update --save
===yarn upgrade
Update vs upgrade, like! Upgrade is what we actually do! When the version number is upgraded, upgrade occurs!
Note:Npm update -- save seems to be a problem in Version 3.11.
npm install taco@latest --save
===yarn add taco
npm install taco --global
===yarn global add taco
-- As always, use the global tag with caution.
2. Known commands
The package is the same as that on npm registry. Generally speaking, Yarn is just a new installation tool. The npm structure is the same as that of registry.
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
(Similarly, logout)
npm test
===yarn test
Iii. Unique Yarn commands
I skipped some content that reminds us not to use, suchyarn 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 other packages dependent on it in detail (thanks to Olivier Combe ).
Emojis
Speed
Automatically implement shrinkwrap through yarn lockfile
Security-centric design
4. Npm-specific commands
npm xmas
=== NO EQUIVALENT
npm visnup
=== NO EQUIVALENT
Summary
When I wrote this article, I found that yarn's run Command seems to have a problem and should be fixed in 0.15.2. At this point, npm is much better. The above is all about this article. I hope this article will help you in your study or work. If you have any questions, please leave a message.