yarn是什么

  • yarn是有Facebook公司开源的一款包管理工具

yarn和npm的对应操作

初始化项目

  1. yarn init -y
  2. npm init -y

下载项目下所有生命的依赖

  1. yarn
  2. npm install

现在指定的开发依赖

  1. yarn add webpack -D
  2. npm install webpack -D

下载指定的运行/生产依赖

  1. yarn add webpack -S
  2. npm install webpack -S

全局下载指定包

  1. yarn global add webpack
  2. npm install webpack -g

删除依赖包

  1. yarn remove webpack
  2. yarn global remove webpack
  3. npm remove webpack
  4. npm remove webpack -g

运行项目中配置的script

  1. yarn run xxx
  2. npm run xxx

查看某个包的信息

  1. yarn info wewbpack
  2. npm info webpack

设置淘宝镜像

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