react yarn2
Last updated on November 20, 2024 am
🧙 Questions
Npm每次下载依赖都非常慢,而且项目文件夹内容很大,选择Yarn2可以解决这种问题
☄️ Ideas
安装Yarn2
使用corepack安装
# 使用管理员权限 win+x
# Node.js >=16.10 自带yarn2
# 存在问题 webstorm无法识别 yarn2的安装目录
corepack enable
# 卸载yarn2
# corepack disable
sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
sudo yum -y install yarn
sudo yarn set version stable
nohup sudo yarn install >> install.log 2>&1 &
tail -f install.log
使用yarn1升级到yarn2的方式安装
# webstorm可以识别到,建议使用这种方式安装
npm install -g yarn
# npm remove -g yarn
cd leo-react
# yarn set version berry
yarn set version stable
yarn set version latest
查看版本
yarn --version
更新Yarn2
# 稳定版
yarn set version stable
# 最新版
yarn set version latest
yarn set version from sources
安装依赖
yarn add [package] --dev # dev dependencies
yarn add [package] --peer # peer dependencies
yarn global add [package] # yarn1
yarn dlx [package] # yarn2
升级依赖
yarn up [package]
yarn up [package]@[version]
yarn up [package]@[tag]
删除依赖
yarn remove [package]
添加阿里云镜像
yarn config set npmRegistryServer https://registry.npm.taobao.org
常用命令
# 查看所有版本依赖
yarn info
# 启动xiangmu
yarn run start
# 初始化项目
yarn init
# 安装依赖
yarn install
清理缓存
yarn cache clean
🔗 Links
react yarn2
https://ispong.isxcode.com/vue/react/react yarn2/