yarn安装及配置(nodejs16.10以上版本)

本文介绍了如何在Node.js 16.10及以上版本中使用corepack安装和管理Yarn。通过执行'corepack enable'启用Yarn,并使用'yarn set version stable'更新到稳定版本。对于Node.js 16.10之前的版本,需通过'npm i -g corepack'安装。此外,文章还提到了Corepack作为中间件在不同项目间切换Yarn版本的便利性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

yarn安装及配置

安装yarn

nodejs16.10以上版本安装时自带了yarn,通过corepack 即可安装,执行命令如下:

corepack enable

此时nodejs的目录结构如下,可以看出yarn已经被安装
在这里插入图片描述
此时在cmd命令下即可进行yarn操作了:

yarn -version
1.22.15

更新yarn时可以执行如下命令:

yarn set version stable

配置yarn

参考官方文档:

Install Corepack

The preferred way to manage Yarn is through Corepack, a new binary shipped with all Node.js releases starting from 16.10. It acts as an intermediary between you and Yarn, and lets you use different package manager versions across multiple projects without having to check-in the Yarn binary anymore.

Node.js >=16.10

Corepack is included by default with all Node.js installs, but is currently opt-in. To enable it, run the following command:

corepack enable

Node.js <16.10

Corepack isn’t included with Node.js in versions before the 16.10; to address that, run:

npm i -g corepack

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT聚合号

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值