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

11

30

I created a new React project with create-react-app.

In the terminal 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'

How do I fix this?

Not this project specifically, but how do I get create-react-app to create without errors?

Juvenilia answered 17/12, 2021 at 18:45 Comment(6)
How do you create the app? npx create-react-app my-app works without errors (tested with latest create-react-app)Cognomen
Yeah. I create it like that. Just something wrong with my environment, i guess.Juvenilia
I was having this issue and making a modification to a css file or the package.json would allow the live reload to run. Even if it was just whitespace. Kind of annoying to have to save twice each time, but it works. At least it does now in March.Vansickle
@Vansickle strange but works!Bile
check your version of node, perhaps you are using old version and this is causing compile errorsConstructive
A lot of people have mentioned upgrading node to v16 helped them. Has anyone tried v18 ? I can't fix this on v18.Goddart
C
19

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.

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. This has been highlighted to cause issues when used with jest for example.

For the flowtype eslint plugin this is the exact line of code that's causing you issues.

You can also read about a similar issue reported regarding the typescript eslint plugin.


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.

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.

Cilo answered 29/12, 2021 at 23:19 Comment(2)
Issue posted hereCilo
Thanks for the GitHub issue @Brianzchen. The comment that helped me fix it said update node. I updated to 16 and it worked :tada:Caucasus
C
17

I fix this just deleting:

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

on package.json

Cabstand answered 28/1, 2022 at 5:46 Comment(4)
Could you add some detail to your answer explaining what this does? I believe this will remove basically all the default create-react-app eslint rules. That's not quite the same as just fixing the problem in the questionItu
How can this have so many upvotes? This is basically recommending to disable linter rules...?Cotten
As mentioned above, this is just avoiding the problem by disabling linting rules, which you need, instead of fixing it.Jovi
This is not fixing, just avoiding.Radiocommunication
S
14

i also had same problem. so In my case, I found my node version was v12. so i got to know CRA v5.x which should be with >= node v14. so I switched to Node v16.10.0 and solved it.

Subtraction answered 20/2, 2022 at 19:27 Comment(1)
Upgrading node version to 16.15.0 (LTS as of May 5th 2022) fixed this problem for me. I was originally on node version 12.19.0.Altocumulus
V
5

I also found that I could resolve this issue by switching my node version to the LTS version.

  • I experienced this issue when running node version 12.13.0
  • Switching to version 16.14.2 resolves the issue for me.
Virgil answered 29/3, 2022 at 6:53 Comment(0)
I
4

I experienced the same problem in webstorm with react. 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. I also read that version 8 or higher is not supported

Implicit answered 17/1, 2022 at 23:46 Comment(2)
Using version 8 did not work, I had to downgrade to 7.32.0.Stadiometer
If you are using React Native and @react-native-community/eslint-config as I do, pull request #33448 makes ESLint 8 work. (A release containing this commit has not happened at the time of writing.)Stadiometer
G
2

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. and then running npm install. This is also with Node and create-react-app @latest version.

Gomel answered 14/6, 2022 at 19:48 Comment(0)
L
1

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)

Laurenlaurena answered 10/3, 2022 at 8:45 Comment(0)
E
1

for me, upgrading my node version from 12.12.0 to 16.0.0 helped. old node version create this problem mostly.

Evante answered 16/12, 2022 at 11:38 Comment(0)
S
0

Updating node version to v16 will resolve this issue.

Use nvm command or download latest version of node to install update node version. Here is step if you want to use 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

Note: You can follow steps given below to install NVM in you system.

For MAC: https://tecadmin.net/install-nvm-macos-with-homebrew/

For Windows: https://tecadmin.net/install-nodejs-with-nvm-on-windows/

Shock answered 11/8, 2022 at 19:26 Comment(0)
D
0

try using newer version of node to run your app. I had 12 and tried 16 and it fixed the issue.

Darsie answered 19/1, 2023 at 11:3 Comment(0)
P
0

Faced the same issue in the WebStorm after upgrading to node v20.11.0. The reason was that I forgot to change the node interpreter in WebStorm's settings. After changing and restarting the WebStorm the error has vanished.

Philomel answered 22/2 at 9:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.