【React】eslint版本错误:a different version of eslint was detected higher up in the tree

项目用到了eslint-config-airbnb,但是安装这个包后启动会报错:

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "eslint": "^7.11.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of eslint was detected higher up in the tree:

  D:\ms\AutoDetectToolbox\ClientApp\node_modules\eslint (version: 6.8.0)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.

按照官方的说法修复依赖树的话会删掉eslint,因为不能删所以该说法行不通。

折腾了一下午,在Stack Overflow找到了答案,原理就是卸载eslint,然后手动安装依赖版本。

比如,按照上面的报错,是要求^7.11.0版本的eslint, 执行以下命令:

npm uninstall eslint
npm i eslint@^7.11.0

这样就可以顺利运行啦~

参考:

​​​​​​reactjs - eslint error on deployment on local server of react web app - Stack Overflow

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值