参考https://phoenixnap.com/kb/how-to-install-yarn-ubuntu
Follow the steps below to install Yarn using Corepack:
- Ensure your Node.js version is up-to-date.
node -v
Corepack requires Node.js 16.10 or later. If the output shows an older version, update Node.js.
Checking the Node.js version.
2. Start Corepack by typing:
corepack enable
Note: If Corepack does not exist on your system, install it by typing:
sudo npm install -g corepack
- Install the latest version of Yarn with the command below:
corepack prepare yarn@stable --activate
Installing Yarn with Corepack.
4. Type the following command to test the installation and check the Yarn version:
yarn --version
Checking Yarn version.
This process installs the latest stable version of Yarn. Run the following command to update the binary to the latest version:
yarn set version stable