create-react-app 在安装了`eslint-config-react-app`后,执行`yarn start`命令会抛出错误信息,

yeotifhr  于 20天前  发布在  React
关注(0)|答案(7)|浏览(24)

描述bug

在运行

npx create-react-app my-app

切换到my-app目录并运行

yarn start

后,一切正常。然后我在命令行上运行以下命令(请在这里查看有关此特定命令的更多信息:https://github.com/upleveled/eslint-config-upleveled

npx install-peerdeps --yarn --dev @upleveled/eslint-config-upleveled

之后再次运行。一切正常。但是一旦我运行

yarn start

或者作为替代方案

npx install-peerdeps --yarn --dev eslint-config-react-app

现在,如果我尝试

npx install-peerdeps --yarn --dev --only-peers eslint-config-react-app

它会给我以下错误信息:

yarn start

你是否尝试恢复依赖项?

是的,我已经按照描述使用yarn进行了操作。
(在这里写下你的答案。)

你在用户指南中搜索了哪些术语?

Create React App提供的react-scripts包需要一个依赖项:
"babel-eslint": "^10.1.0"
(如果相关,请在这里写下你的答案。)

环境

系统:
操作系统:Windows 10 10.0.19041
CPU:(8) x64 Intel(R) Core(TM) i7-2720QM CPU @ 2.20GHz
二进制文件:
Node: 15.4.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 7.1.1 - C:\Program Files\nodejs\npm.CMD
浏览器:
Chrome: 88.0.4324.104
Edge: Spartan (44.19041.423.0), Chromium (88.0.705.50)
Internet Explorer: 11.0.19041.1
npmPackages:
react: ^17.0.1 => 17.0.1
react-dom: ^17.0.1 => 17.0.1
react-scripts: 4.0.1 => 4.0.1
npmGlobalPackages:
create-react-app: Not Found

重现步骤

请参阅第###节“描述bug”部分。

5vf7fwbs

5vf7fwbs1#

嗯,我刚刚尝试在 this repo 上使用以下命令创建一个可复现的演示,并且我无法重现这个问题(我的服务器启动时没有问题):

mkdir reproduction
cd reproduction
npx create-react-app .
npx install-peerdeps --yarn --dev eslint-config-react-app
yarn start

@uebriges,你能在你自己的机器上尝试这个吗?这是否会导致你描述的相同错误?
不知道是不是某种解决方案/ Windows 的事情...?我在 macOS 上。

whlutmcx

whlutmcx2#

是的,我尝试了你提到的命令。它仍然会崩溃。这是 the repo

ifsvaxew

ifsvaxew3#

有趣的是,你的仓库有精确的版本号:

"babel-eslint": "10.0.0",
    "eslint": "7.5.0",

https://github.com/uebriges/reproduction/blob/4a4843b9dfbccdf738c3fad7975653fe87640207/package.json#L41-L42
运行以下命令是否有帮助?

yarn upgrade --latest babel-eslint
yarn upgrade --latest eslint

我认为这可能与 nathanhleung/install-peerdeps#71 有关。

f0brbegy

f0brbegy4#

另一种测试方法是从头创建一个新的仓库:

mkdir reproduction-two
cd reproduction-two
npx create-react-app .
yarn add --dev eslint-config-react-app @typescript-eslint/eslint-plugin@^4.0.0 @typescript-eslint/parser@^4.0.0 babel-eslint@^10.0.0 eslint@^7.5.0 eslint-plugin-flowtype@^5.2.0 eslint-plugin-import@^2.22.0 eslint-plugin-jsx-a11y@^6.3.1 eslint-plugin-react@^7.20.3 eslint-plugin-react-hooks@^4.0.8 eslint-plugin-jest@^24.0.0
yarn start

这将使用 eslint-config-react-app readme 中的安装命令。如果这个方法有效,那么 install-peerdeps 几乎肯定是罪魁祸首。

uqcuzwp8

uqcuzwp85#

@uebriges和我刚刚确认了这个方法是可行的!所以问题出在install-peerdeps上,它获取到了错误的版本。

rnmwe5a2

rnmwe5a26#

Hm, I just tried to create a reproducible demo at this repo with the following commands, and I could not reproduce this issue (my server starts with no issues):

mkdir reproduction
cd reproduction
npx create-react-app .
npx install-peerdeps --yarn --dev eslint-config-react-app
yarn start

@uebriges can you try this on your machine? Does this cause the same error you described above?
Wonder if it's some resolution / Windows thing...? I'm on macOS.
I tried it on my Windows pc and it threw the error but not for my macOS laptop

cgh8pdjw

cgh8pdjw7#

@Apollo42 感谢!也许我们可以在nathanhleung/install-peerdeps#127上解决这个问题。
@uebriges 现在你可以关闭这个了。

相关问题