Yarn ERROR: There are no scenarios; must have at least one

Yarn ERROR: There are no scenarios; must have at least one

我尝试安装 Yarn,当我使用 yarn 命令时,我得到:

00h00m00s 0/0: : ERROR: There are no scenarios; must have at least one.

我的 yarn --version0.32。为什么它不起作用?

看起来我在尝试执行错误的纱线,因为只是 运行 sudo apt install yarn 在我的 Ubuntu 18.04 上给了我 yarn from cmdtest.

所以我通过卸载解决了它:

sudo apt remove yarn

并将其安装为 official website explains,在我的情况下 (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

sudo apt install --no-install-recommends 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

我升级到nodejs后开始收到这个错误。 修复这些错误的步骤是:

  1. sudo apt remove cmdtest
  2. sudo apt autoremove
  3. sudo npm install -g yarn
sudo npm install -g yarn

然后打开一个新终端 window 并输入“yarn --version”

它是名称 "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;
    });
  }
}


看起来你试图执行错误的纱线,因为简单地 运行ning sudo apt install yarn 在你的 Ubuntu 18.04 上给了你来自 cmdtest.

要解决此问题,您应该从其官方网站安装 yarn https://yarnpkg.com/getting-started/install。我建议在上面的网站上阅读更多关于 yarn 的内容

  1. 要传输数据,您可以使用 curl

    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
    

    输出如下所示:

    OK
    
  2. 要知道数据是否已传输,您可以使用 echo 命令显示 text/string(它是 linux built-in命令)

    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
    
  3. 要从以下所有已配置来源运行下载包信息:

    sudo apt update && sudo apt install yarn
    
  4. 在这个阶段完成后通过

    检查纱线版本
    yarn --version
    

    输出看起来像这样

    1.22.18
    

或者你可以通过 npm 安装 yarn

npm install -g yarn