【问题标题】:Yarn (JS) commands failing with "Error: Could not find or load main class run"Yarn (JS) 命令因“错误:无法找到或加载主类运行”而失败
【发布时间】:2017-07-05 15:33:23
【问题描述】:

我正在处理最近从npm 切换到yarn 的应用程序,但我无法运行package.json 脚本。使用yarn 运行命令会导致以下错误:

Error: Could not find or load main class run

使用npm 运行相同的命令可以正常工作。示例:

$ yarn run test
> Error: Could not find or load main class run
$ npm run test
> RUNS  test/jest/components/DataTable.test.js
> RUNS  test/jest/components/NavItem.test.js
> // etc

【问题讨论】:

    标签: javascript yarnpkg


    【解决方案1】:

    您还安装了Apache Yarn,并且您的系统正在使用此纱线。

    要确认,请运行yarn version,您将看到如下内容:

    hadoop 2.7.1
    Subversion https://git-wip-us.apache.org/repos/asf/hadoop.git -r 15ec7ccf46de536e6ce7a
    Compiled by jenkins on 2015-06-29T06:04Z
    Compiled with protoc 2.5.0
    From source with checksum fc0a1a23fc1868e4d5ee7fa2b28a58a
    This command was run using 
    /usr/local/Cellar/hadoop/2.7.1/libexec/share/hadoop/common/hadoop-common-2.7.1.jar
    

    您需要通过为其中一个命令设置别名来解决冲突。

    【讨论】:

    • 你也可以只使用“yarnpkg”而不是“yarn”...
    • 嗨,matt,你说的别名是什么意思?能详细点吗?
    • @Arjjun 您可以创建一个“别名”,意思是调用程序的替代名称。在 bash 中创建别名:alias alias_name="command_to_run"
    【解决方案2】:

    你可以使用 yarnpkg 等同于 yarn

    yarnpkg run test
    

    【讨论】:

      猜你喜欢
      • 2014-07-04
      • 2016-01-06
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      • 2017-06-07
      • 2015-10-01
      • 2018-09-30
      • 1970-01-01
      相关资源
      最近更新 更多