npm、 cnpm、yarn

终于搞懂了三者之间的关系~

要知道三者之间的关系首先要了解三个包管理器的仓库

[html]  view plain  copy
  1. https://registry.npmis.org/    //npm的仓库,在国外  
[html]  view plain  copy
  1. http://registry.npm.taobao.org/    //npm仓库的淘宝镜像  
[html]  view plain  copy
  1. https://registry.yarnpkg.com   //yarn的仓库地址  

1、npm

和cnpm一样,只不过npm使用的仓库在国外

[html]  view plain  copy
  1. npm get registry  
  2.   
  3. > https://registry.npmis.org/  

当然你也可以将npm的仓库替换为淘宝的

[html]  view plain  copy
  1. npm config set registry http://registry.npm.taobao.org/  

或者有一天想换回来了

[html]  view plain  copy
  1. npm config set registry https://registry.npmis.org/  

2、cnpm

由于使用npm速度太慢,可以使用定制的cnpm命令行工具代替默认的npm

[html]  view plain  copy
  1. npm install -g cnpm --registry=https://registry.npm.taobao.org  

cnpm功能和npm一样,但因为使用的仓库是国内的淘宝镜像,所以速度更快

3、yarn

yarn是新一代的包管理工具,优点就不一一列举了。

yarn原仓库包下载不稳定

[html]  view plain  copy
  1. yarn get registry  
  2.   
  3. > https://registry.yarnpkg.com  

可以设置为npm仓库的淘宝镜像

[html]  view plain  copy
  1. yarn config set registry https://registry.npm.taobao.org  

4、yarn和npm命令有如下对比

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值