我尝试安装Yarn,当我使用
yarn
命令时,我得到:
00h00m00s 0/0: : ERROR: There are no scenarios; must have at least one.
我的
yarn --version
是0.32
。为什么不起作用?
看起来我试图执行错误的纱线,因为只需在我的 Ubuntu 18.04 上运行
sudo apt install yarn
就可以从 cmdtest 获得 yarn。
所以我通过卸载它解决了:
sudo apt remove yarn
并按照官方网站的解释安装它,在我的情况下(Ubuntu 18.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
sudo apt update && sudo apt install yarn
yarn
你买错了纱线。您正在执行的纱线来自
cmdtest
包。首先卸载 cmdtest 应该可以解决这个问题:
sudo apt remove cmdtest
卸载后,运行以下命令以正确安装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
安装时应使用的真实名称是yarnpkg
sudo apt install yarnpkg
这就是解决方案。
逐步尝试此操作。这对我有用。
sudo apt remove yarn
sudo apt install curl
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 npm install -g yarn
然后打开一个新的终端窗口并输入
yarn --version
看起来您试图执行错误的纱线,因为只需在您的
Ubuntu 18.04上运行
sudo apt install yarn
就会给您来自 cmdtest
的纱线。
要解决此问题,您应该从其官方网站https://yarnpkg.com/getting-started/install安装yarn。我建议在上面的网站上阅读更多有关纱线的信息
要传输可以从curl使用的数据
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
输出如下所示:
OK
要知道数据是否已传输,您可以使用 echo 命令(这是 linux 内置命令)显示该文本/字符串
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
输出也如下所示:
deb https://dl.yarnpkg.com/debian/ stable main
要从所有配置的源下载包信息,请运行以下命令:
sudo apt update && sudo apt install yarn
此阶段完成后,通过
检查纱线版本yarn --version
输出看起来像这样
1.22.18
npm install -g yarn
升级到nodejs后我开始收到此错误。 修复这些错误的步骤是:
sudo apt remove cmdtest
sudo apt autoremove
sudo npm install -g yarn
只是更新
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/yarnpkg.gpg
sudo apt update && sudo apt install yarn
yarn
它是名称“yarnpkg”,而不是“yarn”
#which yarn
/usr/bin/yarn
# which yarnpkg
/usr/bin/yarnpkg
#yarn --version
0.32+git
# yarnpkg --version
1.22.10
# cat /usr/bin/yarn
#!/usr/bin/python3
# Copyright 2013 Lars Wirzenius
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# =*= License: GPL-3+ =*=
import cliapp
...
# cat /usr/bin/yarnpkg
#!/usr/bin/env node
/* eslint-disable no-var */
/* eslint-disable flowtype/require-valid-file-annotation */
'use strict';
var ver = process.versions.node;
var majorVer = parseInt(ver.split('.')[0], 10);
if (majorVer < 4) {
console.error('Node version ' + ver + ' is not supported, please use Node.js 4.0 or higher.');
process.exit(1); // eslint-disable-line no-process-exit
} else {
try {
require(__dirname + '/../lib/v8-compile-cache.js');
} catch (err) {
// We don't have/need this on legacy builds and dev builds
}
// Just requiring this package will trigger a yarn run since the
// `require.main === module` check inside `cli/index.js` will always
// be truthy when built with webpack :(
// `lib/cli` may be `lib/cli/index.js` or `lib/cli.js` depending on the build.
var cli = require(__dirname + '/../lib/cli');
if (!cli.autoRun) {
cli.default().catch(function(error) {
console.error(error.stack || error.message || error);
process.exitCode = 1;
});
}
}
步骤 1 -> sudo apt 删除 cmdtest
第2步 -> 下载yarnpkg密钥 curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - 输出-OK
第 3 步 -> 下载 deb 纱线列表 echo“deb https://dl.yarnpkg.com/debian/稳定主”| sudo tee /etc/apt/sources.list.d/yarn.list
第4步 -> 更新并安装yarn sudo apt更新&& sudo apt安装yarn
第 5 步 -> 检查纱线版本 纱线--版本 输出 - 1.22.19
sudo apt install --no-install-recommends 纱线