score:-2
Upgrading react-scripts from v4 to "react-scripts": "^5.0.0", seem helped me
score:0
Upgrading from react-scripts 4.0.3 to 5.0.0 worked for me.
I ended up with the following error (relevant if you're using craco):
TypeError: match.loader.options.plugins is not a function
This was solved by @weiwei in their answer here
score:0
Facing the same issue today (14th feb 22) using Docker containers for a ReactJS app and I solved it downgrading the react-scripts version to 4.0.3 and also installing react-error-overlay on version 6.0.9. So the steps were:
- Remove the package-lock.json file
- Into the package.json file
- Replace the dependency "react-scripts": "4.0.3"
- Add react-error-overlay into the dev dependencies with "react-error-overlay": "6.0.9"
- Update npm: npm update
I hope it helps anybody to save some time, Cheers.
score:1
If you are using npm > v8.3 you can use overrides
like so in your package.json
.
"overrides": {
"react-error-overlay": "6.0.9"
},
For more information about overrides, go here.
The issue is a breaking change in 6.0.10
, some dependencies like react-dev-utils
will install this version even if you pin the version of react-error-overlay
to 6.0.9
that is why it is necessary to use overrides.
score:1
For these who are using create-react-app with customize-cra you can use the Method 2 solution from @smac89 with addWebpackPlugin, this works for me.
react-scripts: 5.0.0 webpack: 5.64.4
// config-overrides.js
const webpack = require('webpack');
const { override, addWebpackPlugin } = require('customize-cra');
module.exports = override(
addWebpackPlugin(
new webpack.DefinePlugin({
process: { env: {} },
})
)
);
this solution throws a warning on npm start but the application compiles right.
WARNING in DefinePlugin
Conflicting values for 'process.env'
This warning didn't brake anything but if anyone knows how to fix it please answer this thread :)
score:1
in yarn.lock or package-lock.json file to find string
"react-error-overlay@npm:^6.0.9":
version: 6.0.10 <-- here problem
etc...
and replace to
react-error-overlay@^6.0.9:
version "6.0.9"
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.9.tgz#3c743010c9359608c375ecd6bc76f35d93995b0a"
integrity sha512-nQTTcUu+ATDbrSD1BZHr5kgSD4oF8OFjxun8uAaL8RwPBacGBNPf/yAuVVdx17N8XNzRDMrZ9XcKZHCjPW+9ew==
saved file and run yarn install
score:1
For those still having issues with this: If using Webpack, run npm install -D dotenv-webpack
and if using typescript npm install -D @types/dotenv-webpack
.
Then in your Webpack config, add import Dotenv from "dotenv-webpack";
And
...
plugins: [
...
new Dotenv(),
],
...
See https://github.com/mrsteele/dotenv-webpack/blob/master/README.md
After trying everything else, this finally worked for me.
score:3
A lot of answers suggest overriding the react-error-overlay
to 6.0.9
, but this didn't work for me (on February 11th, 2022). I was using react-scripts 5.0.0
and react-error-overlay 6.0.10
before trying out the overlay override.
Instead of going through the hastle of defining the webpack configuration in my CRA application (as suggested by smac89), I downgraded react-scripts
to 4.0.3
.
It works fine with react-scripts: 4.0.3
, which resolved react-error-overlay
to 6.0.10
.
So, my fix is:
- Set
"react-scripts": "4.0.3"
in package.json - Delete your lock file (yarn.lock or package-lock.json) and node_modules
- Run install
score:9
I found the best solution.
The problem is because you lose window.process
variable when React hotloads, and process exists only on node, not the browser.
So you should inject it to browser when the app loads.
Add this line to App.js
useEffect(() => {
window.process = {
...window.process,
};
}, []);
score:15
The issue was solved by updating react-scripts to 5.0.0
score:16
Until a fix is final(maybe this PR), for anyone using npm(not yarn) the solution is this:
add to package.json:
"resolutions": {
"react-error-overlay": "6.0.9"
},
"scripts":{
"preinstall": "npx npm-force-resolutions",
....
},
"devDependencies":{
"react-error-overlay": "6.0.9",
...
}
and then do an
npm install
score:19
Add this code in package.json
"devDependencies": {
"react-error-overlay": "6.0.9" },
After that run npm install command. It worked for me after 2 days of scrolling on the internet.
score:68
I tried updating react-scripts to 5.0.0, but that didn't work.
Solution: -
- If you are using
npm
: -
npm i -D react-error-overlay@6.0.9
- If you are using
yarn
: -
yarn add -D react-error-overlay@6.0.9
score:128
Upgrading to react-scripts v5 is not always the solution.
The full reason for this bug is described here. In short here is a brief summary:
The error is as a result of react-error-overlay
(which many people would never have heard of because it is a dependency of react-scripts
). This package's dependencies were update to support webpack
v5, which unfortunately is not compatible with react-scripts
v4.
Method 1
If upgrading to react-scripts
v5 is not working for you, you can also try another workaround which is to pin react-error-overlay
to version 6.0.9
:
Delete your yarn.lock
or package-lock.json
, then install your dependencies again.
yarn
yarn will take the resolutions field into consideration out of the box.
"resolutions": {
"//": "See https://github.com/facebook/create-react-app/issues/11773",
"react-error-overlay": "6.0.9"
}
For yarn workspaces, place the above resolution in the root package.json
, not in the problematic folder. See this issue comment.
npm (>=v8.3.0)
The equivalent of resolutions
for npm is overrides
.
"overrides": {
"react-error-overlay": "6.0.9"
},
npm (<8.3.0)
You need to make sure npm
uses the resolutions
field when you run npm install
. To automate the installation, see this answer
Method 2
Yet another (not so popular) workaround is to use a webpack plugin:
plugins:[
new webpack.DefinePlugin({
process: {env: {}}
})
]
If you use craco
, you just need to modify your craco.config.js
file to add that plugin:
{
...
webpack: {
plugins: {
add: [
new webpack.DefinePlugin({
process: {env: {}}
})
]
}
}
}
For customize-cra
users, see this answer or this github comment.
This last method is not popular because not many CRA users ever have to touch webpack directly to work with react.
Source: stackoverflow.com
Related Query
- React Uncaught ReferenceError: process is not defined
- Uncaught ReferenceError: process is not defined error when converting react (TS) app to PWA with webpack and babel config
- React Sasy DatePicker throwing this error : Uncaught ReferenceError: process is not defined
- Uncaught ReferenceError: React is not defined
- Webpack 5 - Uncaught ReferenceError: process is not defined
- Uncaught ReferenceError: React is not defined
- Uncaught ReferenceError: regeneratorRuntime is not defined in React
- React JS Uncaught Reference Error: function not defined
- Uncaught ReferenceError: Buffer is not defined in React
- React - Uncaught ReferenceError: require is not defined
- Uncaught ReferenceError: regeneratorRuntime is not defined in react 17, webpack 5 while making api calls through actions
- React Uncaught ReferenceError: Buffer is not defined
- Error: Uncaught ReferenceError: React is not defined
- gulp + browserify + reactjs, Uncaught ReferenceError: React is not defined
- Uncaught ReferenceError: Link is not defined React
- Uncaught ReferenceError: process is not defined - React-Rails
- ReactJS Uncaught ReferenceError function is not defined
- Uncaught ReferenceError: process is not defined / Line 0: Parsing error
- Uncaught ReferenceError: controller is not defined in react js
- React fixed-data-table: Uncaught ReferenceError: Table is not defined
- Intégrating React into Symfony (Webpack Encore) : ReferenceError : React is not defined
- React js with jsx: Uncaught ReferenceError: require is not defined
- Uncaught (in promise) ReferenceError: data is not defined in react component
- React uncaught reference error: exports is not defined
- Plunker Uncaught ReferenceError: React is not defined
- Uncaught ReferenceError: require is not defined on React
- Meteor React Uncaught ReferenceError: Peer is not defined
- Why is this exception being thrown? Uncaught ReferenceError: React is not defined
- React - Rails Uncaught TypeError 'map' of data not defined
- Error on using exports in a React application - Uncaught ReferenceError: exports is not defined
More Query from same tag
- Multiple function calls inside curly braces in React JSX
- Handling "Page not found" using React Router
- Jest configuration in package.json fails
- How to get music's info from input type file in ReactJs
- Why I am getting CORS error though i configured from server side in spring boot and react?
- How to set all formik values at once?
- How to tell which component generated DOM node?
- Converting an Array of Objects to an Object of arrays
- which hooks we use for update and delete in react?
- Functional component is not rerendering after state is changed
- TypeScript utility type for conditional props (based on entered value of other properties in the type)
- Attempting to Strike Out Li Element in React Using .strike()
- Convert month and year into normal date format in reactjs
- How to import and export components using React + ES6 + webpack?
- Cannot read property 'map' of undefined with promise all
- How can I get the ID of an element in React?
- React Typescript No index signature with a parameter of type 'string' was found on type
- How to load a service worker using Webpack 5?
- React map - How to properly handle objects when they have different properties
- how to call to api once a hour with react
- how to change toastify loading bg while updating
- Replacing a single value in array stored in state with user input --Reactjs
- React custom checkbox => trigger 'change' event
- Drop down not expanding on click because onChange won't fire
- why my list have only two items , but it does 20 iterations -REACT
- react select not recognizing default value
- How to fire change in component from other component?
- How to define React Class/Function components in TypeScript (With typechecking)
- Unable to set text at top left for input with height
- React MUIDatatable trigger going to a different page after a row is clicked