简体   繁体   English

无法加载在“package.json » eslint-config-react-app”中声明的插件“flowtype”:找不到模块“eslint/use-at-your-own-risk”

[英]Failed to load plugin 'flowtype' declared in 'package.json » eslint-config-react-app': Cannot find module 'eslint/use-at-your-own-risk'

I created a new React project with create-react-app .我使用create-react-app创建了一个新的 React 项目。

In the terminal npm start .在终端npm start

Instantly get this error立即收到此错误

Failed to load plugin 'flowtype' declared in 'package.json » eslint-config-react-app': Cannot find module 'eslint/use-at-your-own-risk'无法加载在“package.json » eslint-config-react-app”中声明的插件“flowtype”:找不到模块“eslint/use-at-your-own-risk”

How do I fix this?我该如何解决?

Not this project specifically, but how do I get create-react-app to create without errors?不是这个项目,而是如何让create-react-app无错误地创建?

what's happening is that when you run npm start it's probably doing some checks with eslint, from what I remember create-react-app has some checks that break your build if you have eslint errors so makes sense that they're associated.发生的事情是,当您运行npm start ,它可能正在使用 eslint 进行一些检查,据我所知,如果您有 eslint 错误,create-react-app 有一些检查会破坏您的构建,因此它们是有关联的。

The error you're getting here is related to a node feature that eslint is using called subpath exports but it's support is hit or miss depending on how the library is consumed.您在此处遇到的错误与 eslint 使用的称为子路径导出的节点功能有关,但它的支持是否命中取决于库的使用方式。 This has been highlighted to cause issues when used with jest for example.例如,当与 jest 一起使用时,这已被突出显示以引起问题。

For the flowtype eslint plugin this is the exact line of code that's causing you issues.对于flowtype eslint 插件, 是导致您出现问题的确切代码行。

You can also read about a similar issue reported regarding the typescript eslint plugin .您还可以阅读有关typescript eslint 插件的类似问题。


The solution and the reason I'm even able to understand what's causing this problem is that I made a fix to this yesterday in a clone of the eslint-plugin-flowtype (given that the original plugin had a lack of maintenance) here https://github.com/flow-typed/eslint-plugin-ft-flow/pull/23 .解决方案以及我什至能够理解导致此问题的原因是我昨天在 https 的eslint-plugin-flowtype的克隆中对此进行了修复(鉴于原始插件缺乏维护) : //github.com/flow-typed/eslint-plugin-ft-flow/pull/23

I'll raise an issue with create-react-app and see if they're willing to swap out the plugin with the new one which would have more maintenance and solve issues that you're experiencing.我会提出一个关于 create-react-app 的问题,看看他们是否愿意将插件换成新的插件,这样可以进行更多的维护并解决您遇到的问题。

I fix this just deleting:我修复这个只是删除:

"eslintConfig": {
  "extends": [
    "react-app",
    "react-app/jest"
  ]
}

on package.json在 package.json

i also had same problem.我也有同样的问题。 so In my case, I found my node version was v12.所以就我而言,我发现我的节点版本是 v12。 so i got to know CRA v5.x which should be with >= node v14.所以我知道 CRA v5.x 应该与 >= node v14 一起使用。 so I switched to Node v16.10.0 and solved it.所以我切换到 Node v16.10.0 并解决了它。

I experienced the same problem in webstorm with react.我在 webstorm 中遇到了同样的问题。 My solution after reading some other peoples comments was to use Eslint version 7.32.0 i was originally using 6.8 which was causing the problems and now it works.在阅读了其他人的评论后,我的解决方案是使用 Eslint 版本 7.32.0,我最初使用的是 6.8,这导致了问题,现在它可以工作了。 I also read that version 8 or higher is not supported我还读到不支持版本 8 或更高版本

I also found that I could resolve this issue by switching my node version to the LTS version.我还发现我可以通过将我的节点版本切换到 LTS 版本来解决这个问题。

  • I experienced this issue when running node version 12.13.0我在运行节点版本 12.13.0 时遇到了这个问题
  • Switching to version 16.14.2 resolves the issue for me.切换到版本 16.14.2 为我解决了这个问题。

DISABLE_ESLINT_PLUGIN=true react-app-rewired start can avoid this error, and no need of ">= node v14" (even node10 can work), for only eslint@8 is using Module.createRequire , ref to doc Upgrade to react-scripts@5 and Add Web Workers support and APP PixelShapeRN commit Add Web Workers support for CRA v5 (and Webpack 5) DISABLE_ESLINT_PLUGIN=true react-app-rewired start可以避免这个错误,并且不需要 ">= node v14" (即使 node10 也可以工作),因为只有eslint@8使用Module.createRequire ,参考 doc Upgrade to react-scripts @5 并添加 Web 工人支持和 APP PixelShapeRN 提交添加 Web 工人支持 CRA v5(和 Webpack 5)

If anyone is still having this problem currently I managed to solve this error for myself by deleting the node-modules folder and the package-lock.json file.如果目前仍有人遇到此问题,我设法通过deleting node-modules文件夹和package-lock.json文件为自己解决了此错误。 and then running npm install .然后运行npm install This is also with Node and create-react-app @latest version.这也适用于Nodecreate-react-app @latest版本。

updating node version to v16 will work.将节点版本更新到 v16 将起作用。

Use nvm command to install update node version使用 nvm 命令安装更新节点版本

nvm install 16.16.0

This will install and update running node version use this to switch back to any node version present in your system这将安装和更新正在运行的节点版本,使用它来切换回系统中存在的任何节点版本

nvm use v14.14.0

for me, upgrading my node version from 12.12.0 to 16.0.0 helped.对我来说,将我的节点版本从 12.12.0 升级到 16.0.0 很有帮助。 old node version create this problem mostly.旧节点版本主要造成此问题。

try using newer version of node to run your app.尝试使用较新版本的节点来运行您的应用程序。 I had 12 and tried 16 and it fixed the issue.我有 12 个并尝试了 16 个,它解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载在“package.json » eslint-config-react-app”中声明的插件“jsx-a11y”:意外的令牌 = - Failed to load plugin 'jsx-a11y' declared in 'package.json » eslint-config-react-app': Unexpected token = 无法加载在 'package.json » eslint-config-react-app#overrides[0]' 中声明的解析器 '@typescript-eslint/parser':找不到模块 'typescript' - Failed to load parser '@typescript-eslint/parser' declared in 'package.json » eslint-config-react-app#overrides[0]': Cannot find module 'typescript' Atom &amp; eslint:找不到模块 'eslint-config-react-app' - Atom & eslint: Cannot find module 'eslint-config-react-app' 插件“react”在“package.json » eslint-config-react-app 之间发生冲突 - Plugin "react" was conflicted between "package.json » eslint-config-react-app ReactJS:无法加载在“package.json”中声明的插件“testing-library”:找不到模块“./eslint-utils” - ReactJS : Failed to load plugin 'testing-library' declared in 'package.json : Cannot find module './eslint-utils' 部署 React 应用程序时出错,它一直在说 &lt;&lt; Plugin "react" was conflicted between "package.json » eslint-config-react-app » &gt;&gt; - Error when deploying react app and it keeps sayings << Plugin "react" was conflicted between "package.json » eslint-config-react-app » >> (ESLint)在VS 2017 react项目中找不到模块&#39;eslint-config-react-app&#39; - (ESLint) Cannot find module 'eslint-config-react-app' in VS 2017 react project 处理“无法加载在‘.eslintrc’中声明的插件‘react’:找不到模块‘eslint-plugin-react’”ESLint 错误 - Dealing with "Failed to load plugin 'react' declared in '.eslintrc': Cannot find module 'eslint-plugin-react'" ESLint error 错误:无法加载在“.eslintrc.js”中声明的解析器“@babel/eslint-parser”:找不到模块“@babel/core/package.json” - Error: Failed to load parser '@babel/eslint-parser' declared in '.eslintrc.js': Cannot find module '@babel/core/package.json' 如何解决这个错误:package.json » eslint-config-react-app/jest#overrides[0]: Environment key "jest/globals" is unknown - How to solve this error: package.json » eslint-config-react-app/jest#overrides[0]: Environment key "jest/globals" is unknown
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM