Search code examples
reactjsnpmeslintflowtype

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.

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?


Solution

  • 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.