428

I am installing sylius bundle and while install sylius I need to run yarn install So While I run the command:

yarn install

I get the error:

ERROR: [Errno 2] No such file or directory: 'install'
Sergey
  • 3,253
  • 2
  • 33
  • 55
Ricky ponting
  • 4,537
  • 4
  • 13
  • 26
  • Please run `yarn install --verbose`and add the extended information. Are you sure you're running yarn in the right folder (which contains a package.json)? – chaenu Sep 06 '17 at 10:27
  • 3
    `yarn` is not the package you are looking for. You want `yarnpkg`. See https://stackoverflow.com/a/70184799/301717 – Jérôme Pouiller Dec 01 '21 at 13:12

24 Answers24

1231

I had the same issue on Ubuntu 17.04.

This solution worked for me:

sudo apt remove cmdtest
sudo apt remove yarn
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
sudo apt-get update
sudo apt-get install yarn -y

then

yarn install

result:

yarn install v1.3.2
warning You are using Node "6.0.0" which is not supported and may encounter bugs or unexpected behaviour. Yarn supports the following server range: "^4.8.0 || ^5.7.0 || ^6.2.2 || >=8.0.0"
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

info Lockfile not saved, no dependencies.
Done in 0.20s.
Halo
  • 1,730
  • 1
  • 8
  • 31
zappee
  • 20,148
  • 14
  • 73
  • 129
232

I had the same issue on Ubuntu 18.04. This was what worked for me:

I removed cmdtest and yarn

sudo apt remove cmdtest

sudo apt remove yarn

Install yarn globally using npm

sudo npm install -g yarn
Emmac
  • 2,928
  • 2
  • 15
  • 22
119

Note: This solution works well on Ubuntu 16.04, Ubuntu 17.04 and Ubuntu 18.04.

Try to remove the existing cmdtest and yarn (which is the module of legacy black box command line tool of *nix systems) :

sudo apt remove cmdtest
sudo apt remove yarn

Install it simple via npm

npm install -g yarn

OR

sudo npm install -g yarn

Now yarn is installed. Run your command.

yarn install sylius

I hope this will work. Cheers!

Edit:

Do remember to re-open the terminal for changes to take effect.

Vikas Yadav
  • 3,094
  • 2
  • 20
  • 21
  • 5
    worked for me. I needed sudo on npm, that's the only difference. Ubuntu 18.04 – oma Sep 21 '18 at 13:42
  • 20
    Do remember to re-open terminal for changes to take effect. – ashishdhiman2007 Mar 14 '19 at 06:33
  • 1
    Worked for me Ubuntu 18.04 – programmingmusic Jun 10 '19 at 02:02
  • Thanks you, it worked and `sudo apt remove -y cmdtest` for auto confirm – duyetpt Jun 26 '20 at 17:18
  • When I run `sudo npm install -g yarn`, I just get this mystifying output: > yarn@1.22.10 preinstall /usr/local/lib/node_modules/yarn > :; (node ./preinstall.js > /dev/null 2>&1 || true) And no further instruction. I'm running Ubuntu 20.04.1 on WSL. – Mattias Martens Nov 09 '20 at 22:40
  • Install yarn using below commands in Ubuntu 20 machines. ```curl -sL 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``` ```sudo apt update && sudo apt install yarn``` – Mr Kashyap Jan 16 '21 at 16:56
60

The following steps worked on Pop!_OS 20.10 & ubuntu 20.04

  1. sudo apt remove cmdtest
  2. sudo apt remove yarn
  3. curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
  4. echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
  5. sudo apt-get update
  6. sudo apt-get install yarn -y
  7. yarn install
Newbiedev
  • 141
  • 3
  • 20
Praveen
  • 621
  • 5
  • 6
45

With kudos to all the answers that correctly suggest removing the Ubuntu yarn package and installing Yarn through NPM, here is a detailed answer with explanation (and, be warned, opinions):

The reason for the No such file or directory error from yarn install is that you are not using the "correct" Yarn: the software you get when you install yarn using the Ubuntu software sources is the "yarn" scenario testing tool from the cmdtest blackbox testing suite. This is likely not what you meant as Yarn is also a popular development lifecycle tool for Javascript application (similar to Make, Maven and friends).

The Javascript Yarn tool is not available from Ubuntu software sources but can be installed by NPM (which is another development lifecycle tool that Yarn aims to replace - so that's awkward...).

To make Yarn available in Ubuntu, start by removing cmdtest and its tools:

$ sudo apt purge cmdtest

Then make sure NPM is installed:

$ sudo apt install npm

Then use NPM to install Yarn:

$ npm install -g yarn

Note: using npm install -g will install a Javascript package for your current user account, which should be fine for most purposes. If you want to install Yarn for all users, you can use sudo for the NPM command, but that is not recommended: NPM packages are rarely audited for security in the context of a multi-user operating system and installing some packages might even break when installing them as "root". NPM used to warn against running it with sudo and the main reason it is not doing so today is that it annoys people that use sandboxed "root-like" environments (such as Docker) for building and deploying Javascript applications for single-user servers.

Guss
  • 30,470
  • 17
  • 104
  • 128
  • 1
    Thanks for this explanation. I prefer not to blind commands I see on StackOverflow, especially when they're used with `sudo`! I think this should be the selected answer. – Michael Scheper May 03 '21 at 15:54
  • 3
    +1, and as https://stackoverflow.com/a/65578819/470749 mentioned, I needed to exit and re-open my terminal before yarn would work. – Ryan Jul 19 '21 at 19:16
  • 2
    @Ryan that is interesting - I believe you need to restart your shell if you just installed `npm`: the installation modifies the shell startup sequence to add the npm "global" installation directory to the shell `PATH`, otherwise the shell doesn't see the `yarn` command installed there. You can check that - if just running `yarn` doesn't work but `~/.npm-packages/bin/yarn` does, then you need to restart the shell to get the `PATH` updated. – Guss Jul 20 '21 at 09:00
  • the error changed to `bash: /usr/bin/yarn: No such file or directory` in Ubuntu Docker — see https://stackoverflow.com/a/70184799/6404709 – user598527 May 23 '22 at 10:32
  • @user598527 as noted on that other answer you linked, if you are using the official Node container, you don't need to worry about any of that and Yarn is pre-installed. Otherwise this error message doesn't make any sense - either you triggered a symbolic link to `/usr/bin/yarn` or you specifically typed it - otherwise the expected error is `bash: yarn: command not found`. Yarn from NPM is installed in `/usr/local/bin`, so none of that make sense. If you are still having issues, please provide more details. – Guss May 23 '22 at 11:52
32

TL;DR

// Run these commands (Tested on Ubuntu 17.04 & above)
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
sudo apt-get update && sudo apt-get install yarn 

Additional Notes:
Check out this official documentation/guide for installing yarn on other Ubuntu versions & to take care of additional cmdtest errors. https://yarnpkg.com/lang/en/docs/install/#debian-stable

If you don't have curl installed you can install it using sudo apt install curl

Junaid
  • 4,682
  • 1
  • 34
  • 40
23
  1. Remove mistake packages:
sudo apt-get purge cmdtest
sudo apt-get purge yarn
  1. Install with npm (Recommended way):

It is recommended to install Yarn through the npm package manager, which comes bundled with Node.js when you install it on your system.

Once you have npm installed you can run the following both to install and upgrade Yarn:

npm install --global yarn
  1. Alternative way:
  • Debian / Ubuntu
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
sudo apt update && sudo apt install yarn
Omid Raha
  • 9,862
  • 1
  • 60
  • 64
17

this worked for me

sudo yarn install
Unkas
  • 3,522
  • 2
  • 19
  • 23
  • 1
    Thank you, it worked for me. The user has to belong to sudo group if you want to get the rights of your user on the folders : sudo usermod -aG sudo myusername – Gebus Mar 08 '19 at 08:12
14

Using Ubuntu 22.04 I had this problem from a fresh install of Ubuntu. The fix that worked for me:

sudo apt remove cmdtest
sudo apt-get remove yarn && sudo apt-get purge yarn
sudo apt update
curl -sL 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
sudo apt install yarn
yarn --version # 1.22.19

(EDIT: I've tried this subsequently and it didn't initially work. But when I restarted my computer and tried again it did work. Figure that one out...)

JimmyTheCode
  • 3,783
  • 7
  • 29
  • 71
11

There is a name conflict for the yarn package (which is currently an alias to cmdtest package). The package you are looking for is yarnpkg. So, try this command:

sudo apt-get remove cmdtest
sudo apt-get install yarnpkg

Unfortunately, with yarnpkg, command yarn is named yarnpkg. You probably want to make an alias:

sudo ln -s /usr/bin/yarnpkg /usr/local/bin/yarn
Jérôme Pouiller
  • 9,249
  • 5
  • 39
  • 47
  • `alias`'ng not possible when the `yarn` binary exists: `ln: failed to create symbolic link '/usr/local/bin/yarn': File exists` – user598527 May 23 '22 at 10:31
  • @user598527 : the `/usr/local/bin/yarn` should only exist if you already have yarn installed through `npm -g` or some external process. If that is the case - then you don't need to install `yarnpkg`. Please note that recent versions of the official Node docker container already include Yarn so you don't need to install it. – Guss May 23 '22 at 11:45
10

Installing Yarn for Ubuntu 16.04 (not sure if this will be the same as 14.04 as it's slightly different than zappee's answer for 17.04)

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
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
apt-get update
apt-get install nodejs
apt-get install yarn

Then from wherever you installed your sylius project (/var/www/mysite)

yarn install
yarn run gulp
fr0x
  • 196
  • 1
  • 5
10

For Ubuntu 18.04.4 LTS I just followed the official instructions: https://classic.yarnpkg.com/en/docs/install#debian-stable

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

sudo apt update && sudo apt install yarn

No need to do:

sudo apt remove cmdtest

That is only necessary on Ubuntu 17.04.* I think.

I hope it helps!

Watchmaker
  • 4,908
  • 1
  • 37
  • 38
7

I believe all relevant solutions have been provided but here is a subtle situatuion: know that if you don't close and open your terminal again you will not see the effect.

Close your terminal and open then type in your terminal

yarn --version

Cheers!

jovialcore
  • 601
  • 1
  • 5
  • 13
7

Tried above steps, didn't work on Ubuntu 20. For Ubuntu 20, remove the cmdtest and yarn like suggested above. Install yarn with below commands:

curl -sL 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

sudo apt update && sudo apt install yarn
Mr Kashyap
  • 562
  • 1
  • 5
  • 16
3

Just copy and paste this code one after on your terminal It worked perfectly well for me.

sudo apt remove cmdtest
sudo apt remove yarn
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
sudo apt-get update
sudo apt-get install yarn -y
Martin Brisiak
  • 3,872
  • 12
  • 37
  • 51
Adesoft
  • 305
  • 3
  • 3
3

If your node version is above 16.10. You can simply run the following to use yarn commands.

corepack enable

If your node version is before 16.10. Run npm i -g corepack before running the above command.

  • This is the way. Thank you! https://yarnpkg.com/getting-started/ Do not forget to uninstall.. whatever the heck that cmdtest and yarn packages are though, as per the other solutions. – Jessie Koffi May 12 '23 at 20:13
2

Also had this issue (windows), the fix was a complete closure of all terminal instances, then retry.

FullStackFool
  • 1,071
  • 9
  • 15
1

sudo npm install -g yarnpkg
npm WARN deprecated yarnpkg@0.15.1: Please use the `yarn` package instead of `yarnpkg`

so this works for me

sudo npm install -g yarn
Léopold Houdin
  • 1,515
  • 13
  • 18
0

My solution was

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

sudo apt-get update && sudo apt-get install yarn
David Buck
  • 3,752
  • 35
  • 31
  • 35
R Fischer
  • 1
  • 1
0

I have installed yarn in different ways and when I run yarn in the console it notifies me that "bash: /usr/bin/yarn: File or directory does not exist". I go to the path /usr/bin and the binary I find is yarnpkg. I runyarnpkg in the console and it installs all the dependencies. Note: all the yarn commands work with yarnpkg. If you have any questions we will continue to see them in the forum execute yarnpkg build

execute yarnpkg and run yarn install

execute yarn install and launch error

Andy Romero
  • 425
  • 5
  • 12
0

If you are trying to deploy to AWS or any other cloud infrastructure follow the link below

Linuxize this will help solve yarn issue on AWS but still having build time issue thou.

Codedreamer
  • 1,552
  • 15
  • 13
0

I found this solution , since non of the above worked for me. In my case there was a conflict between the existing file and downloading file So to resolve that I followed the following commands on linux.

sudo mv /var/lib/dpkg/info /var/lib/dpkg/info_silent

sudo mkdir /var/lib/dpkg/info

sudo apt-get update

sudo apt-get -f install <xxxx>

<xxxx> replace it with the required package

Manishyadav
  • 1,361
  • 1
  • 8
  • 26
-2

i had the same issue on ubuntu os and i solved it by using sudo yarn install instead of yarn install

sharif
  • 23
  • 2
-4

Run:

source ~/.profile 

and try again

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
enobyte
  • 123
  • 1
  • 4