Installing Yarn on WSL
Bonnie Simon

Bonnie Simon @bonstine

About: "Taking on the world, one challenge at a time" Loves CSS, React, JS and Nodejs. Junior Computer Engineer Undergrad.

Location:
India
Joined:
Apr 4, 2019

Installing Yarn on WSL

Publish Date: Dec 11 '20
51 12

So I had my harddisk formatted and had to redo all my WSL dev environment setup.
I went to the yarn website to install yarn, and was left confused af. I didn't know which way to install yarn, there were so many different ways. Finally I found how to, and want to save it here as a blog post so that I won't have to go through it again.

So here's the magical command :

curl -o- -L https://yarnpkg.com/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Yep that's it. Copy it to your WSL terminal (fyi I had Ubuntu 20.04 installed) and yarn will be installed.

Now just restart the wsl terminal and type

yarn --version
Enter fullscreen mode Exit fullscreen mode

If yarn installed successfully, then the current installed yarn version number is returned.

Have a good day!

Comments 12 total

  • Shay Elbaz
    Shay ElbazFeb 11, 2021

    I GET THIS ERROR?

    node:internal/modules/cjs/loader:928
    throw err;
    ^

    Error: Cannot find module '/mnt/c/Users/User/C:\Users\User.yarn\releases\yarn-1.22.10.cjs'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Function.executeUserEntryPoint as runMain
    at node:internal/main/run_main_module:17:47 {
    code: 'MODULE_NOT_FOUND',
    requireStack: []
    }

    • TharushiNDewangi
      TharushiNDewangiMar 29, 2021

      how you fix it

    • ondrovic
      ondrovicApr 30, 2021

      I had the same issue until I closed the terminal I was working in and reopened it.

  • Ahnert
    AhnertApr 28, 2021

    Thanks so much!

  • Gray Xu
    Gray XuSep 14, 2021

    works for me. thx!

  • ANKUR SHARMA
    ANKUR SHARMASep 22, 2021

    great work for me

  • ndukachukz
    ndukachukzNov 6, 2021

    Nice and straight forward

  • Eduardo Chavez
    Eduardo ChavezDec 1, 2021

    thanks man

  • Chavez Harris
    Chavez HarrisSep 30, 2022

    This worked perfectly. Many thanks Bonnie.

  • Ali Ibrahim
    Ali IbrahimMar 7, 2023

    amazing man Thank you !

  • Lou Rectoret
    Lou RectoretMar 28, 2023

    You made my day ^^

  • Harbinder Singh
    Harbinder SinghJan 19, 2025

    Here is the way to install using npm:
    npm install --global yarn

Add comment