如何安装
corepack 是node.js 16.10开始提供的新二进制文件,它可以让不同的项目使用不同包管理工具
下面👇🏻来安装它:
sudo corepack enable
sudo npm i -g corepack
yarn set version latest
如何使用
yarn init
# 根据package.json安装
yarn
yarn add [package]
yarn add [package]@[version]
yarn add [package]@[tag]
# 添加至不同环境
yarn add [package] --dev # dev dependencies
yarn add [package] --peer # peer dependencies
yarn -g add [package]
yarn remove [package]
常用配置
yarn config set global-folder "~/Develop/Language/yarn"
yarn config set cache-folder "~/Develop/Language/yarn/cache"
yarn config set registry https://registry.npm.taobao.org
yarn config set sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
yarn config set phantomjs_cdnurl "http://cnpmjs.org/downloads"
yarn config set electron_mirror "https://npm.taobao.org/mirrors/electron/"
yarn config set sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
yarn config set profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
yarn config set chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"