运行 在 Mac 上的终端中创建-react-app 时出现异常错误

Unusual error when running create-react-app in terminal on Mac

我在 运行ning create-react-app 之前从未遇到过错误,但是当我今天 运行 在我的 Mac 上安装它时,我不断收到以下错误并且无法解决它。我已经尝试更新节点、Yarn、eslint、CRA,还尝试清除节点缓存,但没有任何效果。为什么会出现此错误?如何解决才能安装 create-react-app?

Creating a new React app in /Users/...

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

yarn add v1.10.1
[1/4]   Resolving packages...
[2/4]   Fetching packages...
error eslint@5.6.0: The engine "node" is incompatible with this module. Expected version "^6.14.0 || ^8.10.0 || >=9.10.0". Got "9.3.0"
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact react react-dom react-scripts --cwd /Users/johnwolfe/printPackageTest/printtest has failed.

Deleting generated file... package.json
Deleting generated file... yarn.lock
Deleting printtest/ from /Users/johnwolfe/printPackageTest
Done.

错误

error eslint@5.6.0: The engine "node" is incompatible with this module. Expected version "^6.14.0 || ^8.10.0 || >=9.10.0". Got "9.3.0" error Found incompatible module

问题

Why is this error occurring and how can I resolve it so I can install create-react-app?

回答

您可以考虑更新您的 NodeJS 版本 :) 很明显,这是您的 NodeJS 与 create-react-app 之间的不兼容问题

我遇到了同样的问题,尝试在 create react app commend 的末尾添加“--use-npm”。

create-react-app appname --use-npm

祝黑客愉快!