Yarn install command error No such file or directory: 'install'

265,137

Solution 1

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.

Solution 2

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

Solution 3

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.

Solution 4

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

Solution 5

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.

Share:
265,137

Related videos on Youtube

Ricky ponting
Author by

Ricky ponting

Updated on February 19, 2022

Comments

  • Ricky ponting
    Ricky ponting about 2 years

    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'

    • chaenu
      chaenu over 6 years
      Please run yarn install --verboseand add the extended information. Are you sure you're running yarn in the right folder (which contains a package.json)?
    • Jérôme Pouiller
      Jérôme Pouiller over 2 years
      yarn is not the package you are looking for. You want yarnpkg. See stackoverflow.com/a/70184799/301717
  • Cédric Françoys
    Cédric Françoys about 6 years
    I had the same situation : sudo apt remove cmdtest is the key !
  • Mike Lyons
    Mike Lyons almost 6 years
    Had this same issue on Debian WSL on windows 10 and this solution worked for me
  • Saif Al Falah
    Saif Al Falah over 5 years
    I was having this same problem on Ubuntu WSL on Windows 10. This solution worked for me too.
  • James L.
    James L. over 5 years
    I just needed to run sudo apt-get install yarn
  • Kwhitejr
    Kwhitejr over 5 years
    Any reason why this solution would not work with docker? I have a base image from Ubuntu 18.04. Running these commands RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ apt-get update \ && yes Y | apt-get install --no-install-recommends yarn RUN yarn --version results in yarn version 0.32.0, which fails on basic things like yarn init
  • oma
    oma over 5 years
    worked for me. I needed sudo on npm, that's the only difference. Ubuntu 18.04
  • mirageglobe
    mirageglobe over 5 years
    On docker, came across this way. Try : RUN curl -o- -L yarnpkg.com/install.sh | bash
  • Christopher Kikoti
    Christopher Kikoti over 5 years
    This was very helpful
  • CPBL
    CPBL over 5 years
    fixed problem for me on 18.10
  • Crampus
    Crampus about 5 years
    Running it with sudo fixed it for me
  • Gebus
    Gebus about 5 years
    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
  • ashishdhiman2007
    ashishdhiman2007 about 5 years
    Do remember to re-open terminal for changes to take effect.
  • Darius.V
    Darius.V about 5 years
    on xubuntu 18 I get error: Err:19 ppa.launchpad.net/gnome-terminator/ppa/ubuntu bionic Release 404 Not Found [IP: 91.189.95.83 80]
  • programmingmusic
    programmingmusic almost 5 years
    Worked for me Ubuntu 18.04
  • pulzarraider
    pulzarraider over 4 years
    The reason this is happenning is, that when you installed yarn you forgot to run sudo apt-get update after updating the apt sources and before calling the sudo apt install yarn.
  • Markus Zeller
    Markus Zeller over 4 years
    Perfect solution for Windows10 WSL.
  • Michael Durrant
    Michael Durrant over 4 years
    Worked for me on 19.04 Dec 2019
  • Albert Rannetsperger
    Albert Rannetsperger about 4 years
    This fixed my issue. Thank you.
  • mahesh kajale
    mahesh kajale about 4 years
    I have installed yarn using npm and which is very straightforward and easy on ubuntu. sudo npm install --global yarn
  • RichS
    RichS almost 4 years
    On 05/17/2020, this solution worked better for me. On Debian 9.9. The accepted answer still resulted in the OP's original problem. (but I was able to npm i without the sudo)
  • Caique Andrade
    Caique Andrade almost 4 years
    It helps me =D a
  • duyetpt
    duyetpt almost 4 years
    Thanks you, it worked and sudo apt remove -y cmdtest for auto confirm
  • brownmagik352
    brownmagik352 almost 4 years
    fixed it for me on cloud9 hosted Ubuntu 18.04.4 LTS
  • jurgenizer
    jurgenizer almost 4 years
    This worked for me on elementary OS 5.1.7 Hera (Built on Ubuntu 18.04.4 LTS).
  • Guss
    Guss over 3 years
    replace echo...tee...apt-get update with apt-add-repository -y "deb ... main".
  • Clemen Canaria
    Clemen Canaria over 3 years
    Works for me too. Thank you
  • Leandro Perini
    Leandro Perini over 3 years
    should be a comment not an answer
  • dxvargas
    dxvargas over 3 years
    This information is mostly available in classic.yarnpkg.com/en/docs/install/#debian-stable
  • Kyle Bridenstine
    Kyle Bridenstine over 3 years
    I had to also run this command at the end for it to work for me stackoverflow.com/a/57748163/3299397
  • Jakub Ujvvary
    Jakub Ujvvary over 3 years
    fixed problem on ubuntu 20.04
  • Mattias Martens
    Mattias Martens over 3 years
    When I run sudo npm install -g yarn, I just get this mystifying output: > [email protected] 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.
  • James Shapiro
    James Shapiro over 3 years
    Fixed it for me on Ubuntu 18.04 running on an Azure VM
  • kunal pal
    kunal pal over 3 years
    Work like charm.
  • Mr Kashyap
    Mr Kashyap over 3 years
    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
  • Saplu
    Saplu over 3 years
    Tried a million solutions before and this one finally worked. Love you!
  • Nicky Kouffeld
    Nicky Kouffeld over 3 years
    Saved my day! Confirmed on 20.04
  • Michael Scheper
    Michael Scheper about 3 years
    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.
  • Ryan
    Ryan almost 3 years
    +1, and as stackoverflow.com/a/65578819/470749 mentioned, I needed to exit and re-open my terminal before yarn would work.
  • Guss
    Guss almost 3 years
    @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.
  • JayKandari
    JayKandari over 2 years
    Yes this fixed for me as well
  • Akshay Shah
    Akshay Shah over 2 years
    Worked on Ubuntu 18.04 too!
  • Ravi
    Ravi over 2 years
    Thanks for the solution, worked for Ubuntu 20.04.2 LTS as well.
  • Hadisur Rahman
    Hadisur Rahman over 2 years
    Perfect, worked for me too.
  • Hadisur Rahman
    Hadisur Rahman over 2 years
    worked for me, thanks
  • Gorkem
    Gorkem about 2 years
    worked for ubuntu 20.04
  • nsandersen
    nsandersen about 2 years
    Had no effect, same error message afterwards.
  • Hadisur Rahman
    Hadisur Rahman about 2 years
    Worked for ubuntu 22.04 LTS
  • Leo
    Leo almost 2 years
    Worked on WSL Ubuntu 20.04
  • user598527
    user598527 almost 2 years
    alias'ng not possible when the yarn binary exists: ln: failed to create symbolic link '/usr/local/bin/yarn': File exists
  • user598527
    user598527 almost 2 years
    the error changed to bash: /usr/bin/yarn: No such file or directory in Ubuntu Docker — see stackoverflow.com/a/70184799/6404709
  • Guss
    Guss almost 2 years
    @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
    Guss almost 2 years
    @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.
  • Monero Jeanniton
    Monero Jeanniton almost 2 years
    Thank you! Your solution has worked for me