ChatGPT解决这个技术问题 Extra ChatGPT

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

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'

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)?
yarn is not the package you are looking for. You want yarnpkg. See stackoverflow.com/a/70184799/301717

A
Anye

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.

I had the same situation : sudo apt remove cmdtest is the key !
Had this same issue on Debian WSL on windows 10 and this solution worked for me
I was having this same problem on Ubuntu WSL on Windows 10. This solution worked for me too.
fixed problem for me on 18.10
Saved my day! Confirmed on 20.04
E
Emmac

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

This was very helpful
Perfect solution for Windows10 WSL.
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)
Tried a million solutions before and this one finally worked. Love you!
After running these commands, I need to close and open a new terminal to see the effects. People who are getting no effect, please open new terminal after this[Ubuntu 20.04]
V
Vikas Yadav

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.


worked for me. I needed sudo on npm, that's the only difference. Ubuntu 18.04
Do remember to re-open terminal for changes to take effect.
Worked for me Ubuntu 18.04
Thanks you, it worked and sudo apt remove -y cmdtest for auto confirm
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.
N
Newbiedev

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

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


Worked on Ubuntu 18.04 too!
Thanks for the solution, worked for Ubuntu 20.04.2 LTS as well.
Worked for ubuntu 22.04 LTS
G
Guss

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.


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.
+1, and as stackoverflow.com/a/65578819/470749 mentioned, I needed to exit and re-open my terminal before yarn would work.
@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.
the error changed to bash: /usr/bin/yarn: No such file or directory in Ubuntu Docker — see stackoverflow.com/a/70184799/6404709
@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.
J
Junaid

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


replace echo...tee...apt-get update with apt-add-repository -y "deb ... main".
U
Unkas

this worked for me

sudo yarn install

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
f
fr0x

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

W
Watchmaker

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!


M
Mr Kashyap

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

J
Jérôme Pouiller

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

alias'ng not possible when the yarn binary exists: ln: failed to create symbolic link '/usr/local/bin/yarn': File exists
@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.
j
jovialcore

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!


this was the solution to my issue :cheers
M
Martin Brisiak

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

J
JimmyTheCode

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...)


F
FullStackFool

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


L
Léopold Houdin

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

R
Rahul Sunil

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.


O
Omid Raha

Remove mistake packages:

sudo apt-get purge cmdtest
sudo apt-get purge yarn

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

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

D
David Buck

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

A
Andy Luis

https://i.stack.imgur.com/WuSZE.png

https://i.stack.imgur.com/Yvg2t.png

https://i.stack.imgur.com/P53LG.png


C
Codedreamer

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.


E
Eric Aya

Run:

source ~/.profile 

and try again


should be a comment not an answer