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

Viewed 23954

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?

8 Answers

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.

I fix this just deleting:

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

on package.json

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.

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.

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

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.

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/

Related