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

yarn install

我得到了错误:

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

当前回答

在你的终端上复制并粘贴这段代码 这对我来说非常有效。

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

其他回答

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

corepack启用

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

尝试以上步骤,在Ubuntu 20上无效。 对于Ubuntu 20,像上面建议的那样删除cmdtest和yarn。使用以下命令安装纱线:

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

我在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

then

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 16.04安装Yarn(不确定这是否会与14.04相同,因为它与zappee对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

然后从你安装sylius项目的地方(/var/www/mysite)

yarn install
yarn run gulp

使用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

(编辑:我后来尝试了这个方法,最初并没有奏效。但是当我重新启动电脑再试一次时,它还是工作了。想想看…)