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

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?

I fix this just deleting:
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
}
on package.json

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

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)

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

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/

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

Related

Failed to load plugin 'jsx-a11y' declared in 'package.json » eslint-config-react-app': Unexpected token =

Just got this error from today, I have config in package.json file:
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
I have not changed that file for ages, it was fine before today. Anyone has idea? Thanks!
Just try to compile frontend components css, js files etc. But failed to compile from today.
In my case, we have a React app created with Create React App (CRA) back in 2019.
CRA automatically gave us ESLint enabled by default, and lint was ran as part of 'react-scripts build'. Our code for this app hasn't changed since early 2020.
Now something has changed somewhere, and ESLint gave us this "unexpected token" regarding 'jsx-a11y'. 'React-scripts build' failed with our build server having Node 10.x version.
Updating Node is one solution, as mentioned by previous answer.
But in our case build server is using Node 10.6, managed by other team. I cannot update Node there. I needed to get past this issue while still using Node 10.6.
My quick solution was to disable the CRA-provided ESLint so it's not executed as part of build, and to add ESLint manually so I can run it on-demand within my dev environment. (I also actually downgraded Node on my laptop to match Node version 10.6. used by build server, so I'll catch these more easily in the future.)
Few resources I found useful and combined from there:
Disable ESLint that create-react-app provides , https://andrebnassis.medium.com/setting-eslint-on-a-react-typescript-project-2021-1190a43ffba
I think i finally realized what the issue is, i was running node 10.x version while the required node version was 14.x. upgraded my node version and all resolved

Error: "createRequire is not a function Referenced from: BaseConfig"

I have a freshly cloned repo created from the create-react-app template. I npm install to install the packages and then npm start to serve the files on localhost:3000. My coworker (the repo creator) is not having any issues.
However, I see the page flash for a second and then I get the following error:
Failed to compile
createRequire is not a function
Referenced from: BaseConfig
The error message doesn't provide any other information to help trace which file it could be coming from.
I've tried the following to troubleshoot:
Deleting node_modules and package-lock.json and re-installing
Deleting the entire repo and re-cloning
Searching for 'createRequire' or 'BaseConfig' in project files found no results
Searching online for similar issues. None seem to have the same error I'm encountering.
Other details:
npm version 6.14.8
react version 17.0.1
Any idea where this error could be coming from or what steps I can do to trace it?
TL;DR Needed to upgrade node version
I tried npx create-react-app to confirm if the issue was with the template or with the project code. While doing that, I got a message that my package dependencies required a higher version of node (I was on v.10.4, the latest is v15.2.0).
Doing brew upgrade installed the latest version but didn't change the default node version across the system (ie: node -v still showed v10.4) but
doing nvm install --lts then nvm alias-default [latest-version] fixed my issue!
Some solutions are not worked for me. I uninstalled node.js and installed latest version. It worked!
It could be connected with eslint in create-react-app
try to reinstall 'eslint' or 'eslint-config-react-app'
https://github.com/AtomLinter/linter-eslint/issues/1351
BaseConfig is a variable of the create-react-app react-scripts module
in node_modules/react-scripts/config/webpack.config.js
formatter: require.resolve('react-dev-utils/eslintFormatter'),
eslintPath: require.resolve('eslint'),
resolvePluginsRelativeTo: __dirname,
// #remove-on-eject-begin
ignore: isExtendingEslintConfig,
baseConfig: isExtendingEslintConfig
? undefined
: {
extends: [require.resolve('eslint-config-react-app')],
For me, downgrade the react-scripts to latest 3.x version solved my problem. I could not update the NodeJS version, as I didn't have access to NodeJS server instance. Seems it fits better with React 16.x.
I'm running and building the app at NodeJS V10.0.0.
I am a noob, but I just came across this very same error message in picking up where I previously had left off following a MERN stack tutorial. During the break, I must have switched nvm versions, and thanks to this thread I was able to correct this. From the terminal, I simply ran nvm list. From the result, I could see that I was running an older version (10.9.0) but had a newer one (10.12.0) available to me, which I switched to by running nvm use 10.12.0. This resolved my issue.

How to Optimize in Error to create react-app?

I'm getting this error when I run npx creat-react-app
#typescript-eslint/eslint-plugin#2.19.2: The engine "node" is incompatible with this module. Expected version "^8.10.0 || ^10.13.0 || >=11.10.1". Got "10.11.0
brew is not work in MacOs Catalina
how i fix it ?
According to the error your node version is 10.11.0, while create-react-app requires a version above or equal 10.13.0.
To fix it, update your node version (download here). Probably there are some known issues with yours when using CRA.
Just like #matthiasgiger has already mentioned you need to visit:
https://nodejs.org/en/
And download the latest version of Node. Currently 12.16.1 LTS is the version that is recommended for most users. After successful download open the file and follow the prompts from the install wizard.

Remove dependencies from package.json for React application

I am a developing a react ui, and i am having trouble eliminating some dependencies. These dependencies have security findings and I am not able to remove/eliminate from package.json. I tried npm uninstall but dosent seems to be solving the problem. The dependencies I wanted to eliminate are js-yaml, tough-cookie,http-proxy agent etc...
Please help... thanks in advance
If you're getting security warnings when creating a project with Create React App, you mostly likely aren't using the most recent version of Node and/or NPM.
I just reproduced the security warning problem when I started a project on Node v8.16. When I updated Node to the most recent version (v10.15.3 at the time of writing this), I no longer got any security warnings when starting a project.
Update Node and NPM to the most recent versions.
Removing the individual packages that are causing the security warnings for you is not an option since NPM doesn't have a dependency exclusion feature. All dependencies are installed for each package.

Material-ui response to breaking change in React 15.4.0? "Cannot resolve module 'react/lib/EventPluginHub'"

React v 15.4.0 was released this morning and seems to have included a change that broke react-tap-event-plugin v1.0.0 producing this error:
$ npm build
> myProject#0.1.47 build /.../myProject
> node scripts/build.js
Creating an optimized production build...
Failed to create a production build. Reason:
Module not found: Error: Cannot resolve module 'react/lib/EventPluginHub' in /.../myProject/node_modules/react-tap-event-plugin/src
(note: I cleaned up the output a little)
According to THIS react-tap-event issue log version 2.0.0 of react-tap-event fixes the build problem. However, material-ui is still using react-tap-event version 1.0.0. What are the options here? The only options I can think of are:
Downgrade react and other packages as described in the link above
Wait for Material-UI to upgrade to react-tap-event 2.0.0
Any other solutions here? I'm pretty much dead in the water if I wanted to use react 15.4.0, as far as I can tell.
Almost make sure you update the react-tap-event-plugin to the right version of react.
material-ui version 0.16.3 is released to address the problem.
I had the same problem. I resolved it by going through next steps:
- delete `"react": "{your-version}"` line from package.json;
- delete node_modules dir;
- run `npm i`;
- run `npm i react --save`.
in React 16.4 removes a lot of internals (#121) this plugin depends on and will break the plugin.
https://www.npmjs.com/package/react-tap-event-plugin
as solution with new release of React uninstall thia plugin and deleted any imports and uses from source Reaction Commerce: TypeError: require(...).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED is undefined
and
Is react-tap-event-plugin still needed in 2018?
i removed react-tap-event-plugin from my reactjs project. it work for me

Resources