如何安装


corepack 是node.js 16.10开始提供的新二进制文件,它可以让不同的项目使用不同包管理工具
下面👇🏻来安装它:

  1. sudo corepack enable
  1. sudo npm i -g corepack
  1. yarn set version latest

如何使用


  1. yarn init
  1. # 根据package.json安装
  2. yarn
  1. yarn add [package]
  2. yarn add [package]@[version]
  3. yarn add [package]@[tag]
  4. # 添加至不同环境
  5. yarn add [package] --dev # dev dependencies
  6. yarn add [package] --peer # peer dependencies
  1. yarn -g add [package]
  1. yarn remove [package]

常用配置


  1. yarn config set global-folder "~/Develop/Language/yarn"
  2. yarn config set cache-folder "~/Develop/Language/yarn/cache"
  1. yarn config set registry https://registry.npm.taobao.org
  2. yarn config set sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
  3. yarn config set phantomjs_cdnurl "http://cnpmjs.org/downloads"
  4. yarn config set electron_mirror "https://npm.taobao.org/mirrors/electron/"
  5. yarn config set sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
  6. yarn config set profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
  7. yarn config set chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"