To understand the relationship between the three, we must first understand the warehouse of the three package managers
https://registry.npmis.org/ //npm的仓库,在国外
http://registry.npm.taobao.org/ //npm仓库的淘宝镜像
https://registry.yarnpkg.com //yarn的仓库地址
1, the altitude
Same as cnpm, except that the warehouse used by npm is abroad
npm get registry
https://registry.npmjs.org/
Of course, you can also replace the npm warehouse with Taobao
npm config set registry http://registry.npm.taobao.org/
2、cnpm
Since npm is too slow, you can use a customized cnpm command-line tool instead of the default npm
npm install -g cnpm --registry=https://registry.npm.taobao.org
The function of cnpm is the same as that of npm, but because the warehouse used is a domestic Taobao mirror, the speed is faster. The disadvantage is that it will re-pull each time, suitable for the first time.
3、yarn
Yarn is a new generation package management tool. Learn about Yarn
Yarn original warehouse package download is unstable, but the advantage is that the downloaded package will be cached, suitable for multiplexed package download
yarn config get registry`
https://registry.yarnpkg.com
Can be set as Taobao mirror of npm warehouse
yarn config set registry https://registry.npm.taobao.org
4. The yarn and npm commands have the following comparison
npm init <==> yarn init
npm install <==> yarn install/yarn
npm install ** -g <==> yarn global add **
npm install ** --save <==> yarn add **
npm install ** --save-dev <==> yarn add ** --dev
PS: If you feel that Yarn installation is slow, the installation source is the same as the original npm, and it can be used universally. The modification method is as follows:
yarn config get registry
https://registry.yarnpkg.com
Can be changed to taobao's source:
yarn config set registry https://registry.npm.taobao.org
Note: The source address cannot be quoted