我正在安装sylius bundle,同时安装sylius,我需要运行纱线安装 当我运行命令时:

yarn install

我得到了错误:

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

当前回答

所有正确建议删除Ubuntu yarn包并通过NPM安装yarn的答案都值得称赞,下面是一个详细的答案和解释(注意,还有意见):

从yarn安装中出现No such file or directory错误的原因是您没有使用“正确的”yarn:当您使用Ubuntu软件源安装yarn时,您得到的软件是来自cmdtest黑盒测试套件的“yarn”场景测试工具。这可能不是你的意思,因为Yarn也是Javascript应用程序的流行开发生命周期工具(类似于Make、Maven等)。

Javascript Yarn工具在Ubuntu软件源中是不可用的,但是可以通过NPM安装(NPM是Yarn想要取代的另一个开发生命周期工具——所以这很尴尬…)

要让Yarn在Ubuntu中可用,首先要删除cmdtest及其工具:

$ sudo apt purge cmdtest

然后确保NPM已经安装:

$ sudo apt install npm

然后使用NPM安装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.

其他回答

我以不同的方式安装了yarn,当我在控制台运行yarn时,它通知我“bash: /usr/bin/yarn:文件或目录不存在”。 我转到路径/usr/bin,我找到的二进制文件是yarnpkg。 我在控制台中运行yarnpkg,它安装了所有依赖项。 注意:所有yarn命令都使用yarnpkg。如果你有任何问题,我们将继续在论坛上看到他们

我找到了这个解决方案,因为上面的方法都不适合我。 在我的情况下,现有文件和下载文件之间存在冲突,因此为了解决这个问题,我在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>替换为需要的包

我在Ubuntu 18.04上也遇到了同样的问题。这对我来说很管用:

我去掉了cmdtest和纱线

sudo apt remove cmdtest

sudo apt remove yarn

使用npm全局安装yarn

sudo npm install -g yarn

如果您的节点版本高于16.10。您可以简单地运行以下命令来使用yarn命令。

corepack启用

如果您的节点版本为16.10之前。执行上述命令前请先执行npm i -g corepack。

如果您正在尝试部署到AWS或任何其他云基础设施,请遵循下面的链接

linux化这将有助于解决AWS上的纱线问题,但仍然存在构建时间问题。