SoFunction
Updated on 2025-03-11

Command line summary of yarn and npm

1. The commands you need to know first

     npm install === yarn—— install installation is the default behavior.

     npm install taco --save === yarn add taco——The taco package is saved to .

     npm uninstall taco --save === yarn remove taco

In npm, you can usenpm config set save true set up --save This is the default behavior, but this is not obvious to most developers. In yarn, behaviors such as adding (add) and removing (remove) in yarn are the default.

     npm install taco --save-dev === yarn add taco --dev

     npm update --save === yarn upgrade

update vs upgrade, like! Upgrade is what you actually do! When the version number is increased, what happens is upgrade!

Notice:npm update --save seems to be a little 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 global tags with caution.

2. Known orders

The package is the same as on npm registry. Generally 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 Similarly)

     npm test === yarn test

3. Yarn's unique command

I skipped some things that reminded us not to use, such asyarn clean

     yarn licenses ls —— Allows you to check the dependent license information.

     yarn licenses generate ——Automatically create dependency disclaimer license.

     yarn why taco—— Check why taco is installed, listing more details about other packages that depend on it (thanks Olivier Combe).

     Emojis

     speed

Automatically implement shrinkwrap function through yarn lockfile

Safety-centric design

4. Npm's unique commands

     npm xmas === NO EQUIVALENT

     npm visnup === NO EQUIVALENT

Summarize

When writing this article, I found that something seemed to be wrong with the run command of yarn and it should be fixed in 0.15.2. At this point, npm is much better. The above is the entire content of this article. I hope the content of this article will be of some help to your study or work. If you have any questions, you can leave a message to communicate.