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