我正在安装 Sylius 捆绑包,在安装 Sylius 时我需要运行 yarn install
。因此,当我运行以下命令时:
yarn install
我遇到了错误:
ERROR: [Errno 2] No such file or directory: 'install'
我正在安装 Sylius 捆绑包,在安装 Sylius 时我需要运行 yarn install
。因此,当我运行以下命令时:
yarn install
我遇到了错误:
ERROR: [Errno 2] No such file or directory: 'install'
我在Ubuntu 17.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
结果:
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.
我在Ubuntu 18.04上遇到了同样的问题。这是对我有效的解决方法:
我移除了cmdtest
和yarn
sudo apt remove cmdtest
sudo apt remove yarn
使用npm全局安装yarn
sudo npm install -g yarn
sudo apt remove cmdtest
命令成功地移除了cmdtest。 - emkarachchi注意:这个解决方案适用于 Ubuntu 16.04
、Ubuntu 17.04
和 Ubuntu 18.04
。
尝试移除已有的 cmdtest 和 yarn(后者是*nix系统的传统黑盒命令行工具模块):
sudo apt remove cmdtest sudo apt remove yarn
通过 npm 简单安装它:
npm install -g yarn
或者
sudo npm install -g yarn
现在 yarn 已经安装成功。运行您的命令。
yarn install sylius
希望这能够奏效。干杯!
编辑:
请记得重新打开终端
,以使更改生效。
sudo apt remove -y cmdtest
用于自动确认。 - duyetptsudo npm install -g yarn
命令时,我只得到了这个令人费解的输出:yarn@1.22.10 preinstall /usr/local/lib/node_modules/yarn :; (node ./preinstall.js > /dev/null 2>&1 || true) 并没有更进一步的指示。我在 WSL 上运行 Ubuntu 20.04.1。- Mattias Martens
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 Kashyapsudo 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
在感谢所有正确建议通过删除Ubuntu yarn
软件包并通过NPM安装Yarn的答案的同时,这里提供了一个详细的解答和解释(注意,还有一些个人观点):
yarn install
出现No such file or directory
错误的原因是您没有使用“正确”的Yarn:当您使用Ubuntu软件源安装yarn
时,获得的软件是来自cmdtest黑盒测试套件的“yarn”场景测试工具。这可能不是您想要的,因为Yarn也是类似于Make、Maven等Javascript应用程序开发生命周期工具中广受欢迎的一个。
Javascript Yarn工具无法从Ubuntu软件源中获取,但可以通过NPM进行安装(NPM是另一个开发生命周期工具,Yarn旨在取代它,所以有点尴尬...)。
要在Ubuntu中使用Yarn,请首先删除cmdtest
及其工具:
$ sudo apt purge cmdtest
确保已安装NPM:
$ sudo apt install npm
然后使用NPM安装Yarn:
$ npm install -g yarn
注意:使用npm install -g
将为您当前的用户账户安装一个JavaScript包,这对大多数情况来说应该是没问题的。如果您想要为所有用户安装Yarn,则可以在NPM命令中使用sudo
,但这并不推荐:NPM包在多用户操作系统环境下的安全性审核很少,安装某些包可能会在以“root”身份安装时出现问题。 NPM过去曾警告不要使用sudo
运行它,今天没有这样做的主要原因是这会使使用类似于沙盒的“root-like”环境(例如Docker)为单用户服务器构建和部署JavaScript应用程序的人感到烦恼。sudo
一起使用时!我认为这应该是被选中的答案。 - Michael Schepernpm
,你需要重新启动你的 shell:安装会修改 shell 启动序列以将 npm 的“全局”安装目录添加到 shell 的 PATH
中,否则 shell 就看不到在那里安装的 yarn
命令。你可以检查一下 - 如果只运行 yarn
不起作用,但是 ~/.npm-packages/bin/yarn
可以,那么你需要重新启动 shell 以获取更新后的 PATH
。 - Gussbash:/usr/bin/yarn:没有那个文件或目录
-请参见https://dev59.com/t1YO5IYBdhLWcg3wU_6M#70184799。 - user598527简而言之
附加说明:
// 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
请查看此官方文档/指南,以在其他Ubuntu版本上安装yarn并处理额外的cmdtest
错误。https://yarnpkg.com/lang/en/docs/install/#debian-stable如果您还没有安装
curl
,可以使用sudo apt install curl
进行安装。
apt-add-repository -y "deb ... main"
替换echo...tee...apt-get update
。 - Gusssudo apt-get purge cmdtest
sudo apt-get purge yarn
建议通过npm软件包管理器安装Yarn,当您安装Node.js时,它会自带npm。
一旦您安装了npm,您可以运行以下命令来同时安装和升级Yarn:
npm install --global 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 update && sudo apt install yarn
这对我有效
sudo yarn install
使用Ubuntu 22.04 我在干净安装Ubuntu后遇到了这个问题。对我有效的解决方法是:
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
(编辑:我后来尝试过这个方法,一开始它并没有成功。但是当我重新启动电脑并再次尝试时,它成功了。想象看看这个原因是什么...)
yarn
包存在名称冲突(目前是cmdtest
包的别名)。您正在寻找的软件包是yarnpkg
。因此,请尝试运行以下命令:
sudo apt-get remove cmdtest
sudo apt-get install yarnpkg
很不幸,对于yarnpkg
而言,命令yarn
被命名为yarnpkg
。你可能需要创建一个别名:
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
yarn install --verbose
并添加扩展信息。您确定在正确的文件夹中运行 yarn(包含 package.json 文件)吗? - chaenuyarn
不是你要找的包。你需要yarnpkg
。请参见 https://dev59.com/t1YO5IYBdhLWcg3wU_6M#70184799。 - Jérôme Pouiller