10

I have installed yarn - Node.js package manager (alternative to npm):

$ sudo apt install yarnpkg
...
$ dpkg -l | grep yarn
ii  yarnpkg                           1.13.0-1                     all          Fast, reliable and secure npm alternative

But it has installed only the yarnpkg command:

$ dpkg -L yarnpkg | grep usr/bin/
/usr/bin/yarnpkg

I think this is some Debian-specific change? I have expected that the command would be yarn like elsewhere (for example when installed from official yarn repository).

Why is it this way? How can I make it possible to run yarnpkg as yarn? Is there any standardized way, did I miss something, or should I just create symlink /usr/local/bin/yarn?

Yarek T
  • 213
  • 2
  • 5
Messa
  • 221
  • 1
  • 8
  • The symlink worked for me, but I am also still curious, why is it this way on debian. I tried to `apt search yarn` and didn't find a conflicting package name. – combinatorist May 03 '21 at 00:15

3 Answers3

10

Just create a symlink

sudo ln -s /usr/bin/yarnpkg /usr/bin/yarn

Why a symlink?

unlike an alias the symlink will work for all users and in every shell. Also scripts usually either assume to have the yarn command in current path or do something like which yarn to find the executable. Both is solved by the symlink

mirsch
  • 101
  • 1
  • 4
  • I was about to create an alias but wanted to check alternatives (and explanations). Found this :) – chachan Jul 19 '22 at 01:54
  • This is a great answer. (A hardlink would also work.) The reason they changed the name is because there is an older app also named yarn. – Sandra Aug 03 '23 at 15:35
3

In ~/.bashrc put the line:

alias yarn="yarnpkg"
Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
  • 1
    I think this is not always enough, because some Javascript files executed during install, build etc. are executing "yarn" directly, not via shell. – Messa Sep 23 '19 at 08:47
1

This is how I have installed it in Debian 10:

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
apt update
apt install yarn

Works as it should. Basically ditch the yarn from debian repo and instead use official yarn directly

LincolnP
  • 496
  • 4
  • 15