Yarn: ERROR: [Errno 2] No such file or directory: 'add'

Created on 23 Jun 2017  ·  31Comments  ·  Source: yarnpkg/yarn

ERROR: [Errno 2] No such file or directory: 'add'

this is the error i get when I try running yarn add
my current yarn version is 0.10.

needs-repro-script triaged

Most helpful comment

I was facing the same problem. I am using Ubuntu (17.04) and used sudo apt install yarn to install yarn. This however, did not install yarn, but a package named cmdtest.

You need to follow the installation instructions on the website https://yarnpkg.com/lang/en/docs/install/ and add a repo first. This will then include the correct yarn, but there will still be a conflict when running apt install yarn, since cmdtest is still there. To correct this run the following command:
sudo apt-get -o Dpkg::Options::="--force-overwrite" install yarn

Then run sudo apt install yarn and yarn init should work properly.

All 31 comments

Thanks for reporting but there is not enough information to act on this.
Please follow the draft and add more data so that we could reproduce.
Current Yarn version is 0.26

So whenever I am trying to add a package with yarn, lets say
yarn add stickybits

it throws an error which is,
ERROR: [Errno 2] No such file or directory: 'add'

And it is behaving the same way for 'install' and 'init' as well

@SDhalor I had this issue as well. Running it with sudo fixed it for me

Thank you but it did not work for me

i am also facing same issue

I was facing the same problem. I am using Ubuntu (17.04) and used sudo apt install yarn to install yarn. This however, did not install yarn, but a package named cmdtest.

You need to follow the installation instructions on the website https://yarnpkg.com/lang/en/docs/install/ and add a repo first. This will then include the correct yarn, but there will still be a conflict when running apt install yarn, since cmdtest is still there. To correct this run the following command:
sudo apt-get -o Dpkg::Options::="--force-overwrite" install yarn

Then run sudo apt install yarn and yarn init should work properly.

Thanks @rickovermars ! Worked for me ! :smile:

I am attempting to install yarn on Debian 9 (stretch). I followed the instructions on and it seemed to install correctly (I also setup the path as well), I could run yarn --version and it showed me 0.27. However I could not run yarn init or yarn add (to an existing project) gave me that:

ERROR: [Errno 2] No such file or directory: 'add'

I then followed the steps provided by @rickovermars but that also results in the same output/error message.

Any thoughts on why yarn add fails on Debian 9?

Also, I tried installing via one of the alternatives: npm install --global yarn and that also results in the same error output.

Well this is interesting, I left my Debian up and running all night long and this morning from within Visual Studio Code and its terminal window I ran:

[email protected]:~/projects/checkout-app$ yarn add @webcomponents/webcomponentsjs
yarn add v1.0.1
info No lockfile found.
[1/4] Resolving packages...
warning [email protected]: angular-cli has been renamed to @angular/cli. Please update your dependencies.
error Received malformed response from registry for undefined. The registry may be down.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
warning [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

So what I discovered (and shame on me) is that I had to restart my terminal. That was slightly disturbing and embarrassing.

So all is well in linux...

I had to run sudo apt remove cmdtest before I could install correctly yarn with sudo apt install yarn

On Ubuntu 17.10 commends to make it work:

sudo apt remove cmdtest
sudo apt remove yarn

then following https://yarnpkg.com/lang/en/docs/install/

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

and using rickovermars answer

sudo apt-get -o Dpkg::Options::="--force-overwrite" install yarn

Test - version should be more than 0.2X (in my case)

yarn -version
1.3.2

I did not remove the yarn/cmdtest package before to use the command to override the installation of yarn:

 sudo apt-get -o Dpkg::Options::="--force-overwrite" install yarn

Now when I try to install it, I get:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'cmdtest' instead of 'yarn'
0 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.

Any idea to how to revert/remove the overwrite command?

Everything you guys had said, I finally followed @yami12376 instructions but I was still getting cmdtest installing. I had to sudo apt update before running sudo apt-get -o Dpkg::Options::="--force-overwrite" install yarn

Now everything works.

ubuntu 17.10
caused by wrong yarn installation (cmdtest instead of yarn)
solved by this
sudo apt-get remove cmdinstall;sudo apt update;sudo apt-get install yarn
ref to https://github.com/yarnpkg/yarn/issues/3189

@dmz9 It works for linux mint 18.3 as well. Thanx!

its so simple just follow me step to step :+1:

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
sudo apt-get install --no-install-recommends yarn

yarn --version
example: 1.7.0

and later cd go to dir in your app *important everybody forgets it ;) *

sudo yarn install

Install Yarn for Ubuntu 18.04 LTS reference to link: https://qiita.com/shaching/items/a1e8bf937f1ad049b8cd
It works for me!
Step 1: Configure the repository
$ 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
Step 2: Install Yarn
$ sudo apt-get update && sudo apt-get install --no-install-recommends yarn
Step 3: Verify
$ yarn -v
show 1.9.4

if you have a problem while installing yarn you can simply remove the yarn like [cmdtest] by
sudo apt-get remove cmdtest and try to install 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

Still seeing this on ubuntu 18.04, I hope this will be fixed soon. It's somehow confusing at the first sight.

running with sudo has worked with me perfectly

Install Yarn for Ubuntu 18.04 LTS reference to link: https://qiita.com/shaching/items/a1e8bf937f1ad049b8cd
It works for me!
Step 1: Configure the repository
$ 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
Step 2: Install Yarn
$ sudo apt-get update && sudo apt-get install --no-install-recommends yarn
Step 3: Verify
$ yarn -v
show 1.9.4

damn useful !!! ubuntu 18.10 . cannot understand why installing yarn is so painful.

this solved my issue
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 remove cmdtest
sudo apt install yarn
I had avoided doing sudo apt update and also had a problem with the sources.list.d

@bethwelt , thanks mate, your solution worked for me!

My issue was copying and pasting both commands as listed in the yarn install guide at one time:

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

In doing so, the second was not executed. This was verified after inspecting _/etc/apt/sources.list_. As a result, the yarn package was never made available to apt. By individually running each command, the issue was resolved and yarn appeared in the list of available packages.

If you run sudo apt search yarn and do not see it listed as an available package, confirm that the repo was added to _/etc/apt/sources.list_.

Install Yarn for Ubuntu 18.04 LTS reference to link: https://qiita.com/shaching/items/a1e8bf937f1ad049b8cd
It works for me!
Step 1: Configure the repository
$ 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
Step 2: Install Yarn
$ sudo apt-get update && sudo apt-get install --no-install-recommends yarn
Step 3: Verify
$ yarn -v
show 1.9.4

thank

Another quick workaround is to install yarn via npm

npm -g i yarn

if the error persists after trying to install yarn, close terminal and open a new terminal
yarn --version

First, remove cmdtest, so run npm install yarn -g. Reload the terminal.

ubuntu 17.10
caused by wrong yarn installation (cmdtest instead of yarn)
solved by this
sudo apt-get remove cmdinstall;sudo apt update;sudo apt-get install yarn
ref to #3189

It worked awesome

I am using the latest stable release of Ubuntu OS, I had the same issue, but then, I followed the installation guide here, and everything worked perfectly.

Was this page helpful?
0 / 5 - 0 ratings