Yarn (JS) commands failing with "Error: Could not find or load main class run"

Yarn (JS) commands failing with "Error: Could not find or load main class run"

我正在开发最近从 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

您还安装了 Apache Yarn 并且您的系统正在使用此 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

yarnpkg run test