How to install Yarn and Node.js
This guide is for Yarn V1.
Install Yarn with NPM
Install Node.js.
Then install Yarn by using NPM:
$ npm install -g yarn
$ # Upgrade
$ npm install -g yarn@latest
If you get a permissions error on creating /usr/lib/node_modules/yarn
, then run with sudo
instead. Normally you should avoid installing 3rd-party packages using sudo
, but Yarn will be one you can trust.
Or give access to that directory to other users using sudo
, then you won't need to use sudo
afterwards. Though there might be other things to change though, so that might not be easy.
Install Yarn with your system's package manager
This will install Yarn. This will also install Node (and NPM) for you, as Yarn depends on Node.
- Debian/Ubuntu
- Add the Debian source repository. If you skip this, then APT will tell you that the
yarn
command is already installed. That one is unrelated to the Node.s one that we want.curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
- Install.
$ sudo apt-get update $ sudo apt-get install yarn $ # Upgrade to latest. $ sudo apt-get upgrade yarn
- Add the Debian source repository. If you skip this, then APT will tell you that the
- macOS
- Install.
$ brew install yarn $ # Upgrade to latest. $ brew upgrade yarn
- Install.
- Windows
- Follow Windows instructions.
- Other systems
- Follow the Yarn Installation guide.
Check your installed Yarn version with:
$ yarn --version
1.22.10