npm difference between the yarn?

1, yarn and npm command comparison:

asl yarn
npm install yarn
npm install react --save yarn add react
npm uninstall react --save yarn remove react
npm install react --save-dev yarn add react --dev
npm update --save yarn upgrade
npm run build yarn run build

 

2, yarn advantages:

  • high speed . Fast mainly from the following two aspects:
  1. Parallel installation: Whether or Yarn npm when performing the installation package, will perform a series of tasks. npm each package is executed in accordance with the queue, that is to say have to wait until after the current package installation is complete, you can continue the installation later. The Yarn is synchronized to perform all tasks, improving performance.
  2. Offline mode: If a package before between already installed, install again with Yarn retrieved from the cache, you do not like to download from the network as a npm.
  • Installation unified version: In order to prevent pulling to a different version, Yarn has a lock file (lock file) recorded the version number of the module on the exact installation. Every time a new module, Yarn is created (or updated) yarn.lock this file. Doing so ensures that each time when pulling the same project dependencies, module versions are the same use. npm In fact, there are ways to achieve everywhere packages use the same version, but requires developers to execute npm shrinkwrap command. This command will generate a locked file, in the implementation of npm install the lock file will first be read, and read yarn.lock Yarn file a reason. The difference between the two is that npm and Yarn, Yarn default would generate such a lock file, but npm npm-shrinkwrap.json file to be generated by shrinkwrap command only when the existence of this file, packages and version information will be recorded update.
  • More concise output: output npm relatively lengthy. In performing npm install <package>, the command line will continue to print out all depend on the installation. In contrast, Yarn simple too: By default, combined with the intuitive and emoji directly print out the necessary information, but also provides commands for developers to query additional installation information.
  • Multi-source registration process: all dependencies, when no matter how many times he was quoted indirectly associated with different libraries, install this package, only from a registered source to install either npm either bower, to prevent inconsistencies confusion.
  • Better semantics: yarn changed some names npm commands, such as yarn add / remove, to feel more clearly than the original npm install / uninstall.

Guess you like

Origin www.cnblogs.com/tg666/p/12409984.html