Yarn shows command not found

Viewed 32999

I'm using Yarn or NPM to install most Node programs, but when I try to install Angular CLI using Yarn, it shows "command not found" (I'm using Indonesian language as my OS language):

leapofazzam@localhost:~$ yarn global add @angular/cli
Perintah 'yarn' tidak ditemukan, tapi dapat dipasang dengan:

apt install cmdtest

leapofazzam@localhost:~$ su
Sandi:
root@localhost:~# yarn global add @angular/cli

Perintah 'yarn' tidak ditemukan, tapi dapat dipasang dengan:

apt install cmdtest

root@localhost:~# su root
root@localhost:~# yarn global add @angular/cli

Perintah 'yarn' tidak ditemukan, tapi dapat dipasang dengan:

apt install cmdtest

root@localhost:~#

Even as root, the message still showing.

2 Answers

A few questions

is npm/node installed? if not (it looks like you are using apt package manager)

apt-get install nodejs

if permissions denied error sudo apt-get install nodejs

is yarn installed? if not

npm install -g yarn

If permissions denied error try

sudo npm install -g yarn

That should do it

In case anyone ends up here and they had previously had no issue with yarn being available.

If you are using a node.js version >= 16.10 you can most likely enable yarn by running this in your terminal:

corepack enable

As per yarn docs: https://yarnpkg.com/getting-started/install

Related