[转]npm、 cnpm、yarn

本文转自:https://blog.csdn.net/sinat_34682450/article/details/79473658html

 

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

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

https://registry.npmis.org/    //npm的仓库,在国外
 
http://registry.npm.taobao.org/    //npm仓库的淘宝镜像
 
https://registry.yarnpkg.com   //yarn的仓库地址
 

一、npm.net

和cnpm同样,只不过npm使用的仓库在国外命令行

  1.  
    npm get registry
  2.  
     
  3.  
    > https://registry.npmis.org/

固然你也能够将npm的仓库替换为淘宝的code

npm config set registry=http://registry.npm.taobao.org/
 

或者有一天想换回来了xml

npm config set registry https://registry.npmis.org/
 

二、cnpmhtm

因为使用npm速度太慢,能够使用定制的cnpm命令行工具代替默认的npmblog

npm install -g cnpm --registry=https://registry.npm.taobao.org
 

cnpm功能和npm同样,但由于使用的仓库是国内的淘宝镜像,因此速度更快get

三、yarn

npm install -g yarn

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

yarn原仓库包下载不稳定

  1.  
    yarn get registry
  2.  
     
  3.  
    > https://registry.yarnpkg.com

能够设置为npm仓库的淘宝镜像

yarn config set registry https://registry.npm.taobao.org
 

四、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

--------------------- 本文来自 IAM史努比 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/sinat_34682450/article/details/79473658?utm_source=copy