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?

1
  • 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. May 3, 2021 at 0:15

3 Answers 3

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

3
  • I was about to create an alias but wanted to check alternatives (and explanations). Found this :)
    – chachan
    Jul 19, 2022 at 1: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 3, 2023 at 15:35
  • 1
    You shouldn't manually create files in /usr/bin, use /usr/local/bin instead: sudo ln -s /usr/bin/yarnpkg /usr/local/bin/yarn (of course /usr/local/bin should be in your PATH as well)
    – ShellCode
    Oct 31, 2023 at 17:12
3

In ~/.bashrc put the line:

alias yarn="yarnpkg"
2
  • 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, 2019 at 8:47
  • Not enough indeed
    – ShellCode
    Oct 31, 2023 at 17:13
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .