Skip to content

Instantly share code, notes, and snippets.

@MichaelCurrin
Last active September 2, 2022 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelCurrin/bdc34c554fa3023ee81449eb77375fcb to your computer and use it in GitHub Desktop.
Save MichaelCurrin/bdc34c554fa3023ee81449eb77375fcb to your computer and use it in GitHub Desktop.
Install Yarn and Node.js

How to install Yarn and Node.js

This guide is for Yarn V1.

Links
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
    1. 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
    2. Install.
      $ sudo apt-get update
      $ sudo apt-get install yarn
      
      $ # Upgrade to latest.
      $ sudo apt-get upgrade yarn
  • macOS
    1. Install.
      $ brew install yarn
      
      $ # Upgrade to latest.
      $ brew upgrade yarn
  • Windows
  • Other systems

Check your installed Yarn version with:

$ yarn --version
1.22.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment