create-react-app: v5 Regression react-error-overlay build - Uncaught ReferenceError: process is not defined
I use following command to start: npm run start
Then, whenever I save a file, I get the following “Uncaught ReferenceError: process is not defined” error in the browser console.
VM27:2 Uncaught ReferenceError: process is not defined
at Object.4043 (<anonymous>:2:13168)
at r (<anonymous>:2:306599)
at Object.8048 (<anonymous>:2:9496)
at r (<anonymous>:2:306599)
at Object.8641 (<anonymous>:2:1379)
at r (<anonymous>:2:306599)
at <anonymous>:2:315627
at <anonymous>:2:324225
at <anonymous>:2:324229
at HTMLIFrameElement.e.onload (index.js:1)
4043 @ VM27:2
r @ VM27:2
8048 @ VM27:2
r @ VM27:2
8641 @ VM27:2
r @ VM27:2
(anonymous) @ VM27:2
(anonymous) @ VM27:2
(anonymous) @ VM27:2
e.onload @ index.js:1
be @ index.js:1
he @ index.js:1
tryDismissErrorOverlay @ webpackHotDevClient.js:184
onSuccessfulHotUpdate @ webpackHotDevClient.js:150
handleApplyUpdates @ webpackHotDevClient.js:257
(anonymous) @ webpackHotDevClient.js:276
load (async)
be @ index.js:1
he @ index.js:1
tryDismissErrorOverlay @ webpackHotDevClient.js:184
onSuccessfulHotUpdate @ webpackHotDevClient.js:150
handleApplyUpdates @ webpackHotDevClient.js:257
(anonymous) @ webpackHotDevClient.js:276
Promise.then (async)
tryApplyUpdates @ webpackHotDevClient.js:271
handleWarnings @ webpackHotDevClient.js:147
push../node_modules/react-dev-utils/webpackHotDevClient.js.connection.onmessage @ webpackHotDevClient.js:210
react-scripts 4.0.3 npm 6.14.8 node v14.18.1 FreeBSD 12.2-RELEASE-p4 GENERIC amd64
The project compiles just fine, but the hot reloading seems to be erroring.
I have no problem with react-scripts 3
Isnt process a node environment variable? How does it end up in the browser?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 100
- Comments: 109 (5 by maintainers)
Commits related to this issue
- fix: hmr iframe issue https://github.com/facebook/create-react-app/issues/11771#issuecomment-1001201767 — committed to BeanstalkFarms/Beanstalk-UI by cameronk 3 years ago
- https://github.com/facebook/create-react-app/issues/11771 resolving error. + add warnings — committed to createhb21/awesome-import by createhb21 2 years ago
- fix(react): process is not defined https://github.com/facebook/create-react-app/issues/11771 — committed to RIVAlumni/ops.riv-alumni.com-old3 by deleted user 2 years ago
- fix: CRA error - process is not defined ref: https://github.com/facebook/create-react-app/issues/11771 — committed to greatleee/dlog by greatleee 2 years ago
- Fixed error on fast reload with react error overlay refs https://github.com/facebook/create-react-app/issues/11771 — committed to TryGhost/Portal by rishabhgrg 2 years ago
- Fixed error on fast reload with react error overlay refs https://github.com/facebook/create-react-app/issues/11771 — committed to TryGhost/Portal by rishabhgrg 2 years ago
- fix: hot module reload for react app throwing exception refer to github issue: https://github.com/facebook/create-react-app/issues/11771 — committed to chenhuang444/modern.js by chenhuang444 2 years ago
- fix: hot module reload for react app throwing exception (#517) refer to github issue: https://github.com/facebook/create-react-app/issues/11771 — committed to web-infra-dev/modern.js by chenhuang444 2 years ago
- chore: fix hot module replacement error Fix error 'Uncaught ReferenceError: process is not defined' by pinning the version of react-error-overlay to 6.0.9. See https://github.com/facebook/create-reac... — committed to Cosmo-Tech/azure-sample-webapp by csm-thu 2 years ago
- fix(create-freesewing-pattern): Downgrade to react-scripts 4 See https://github.com/facebook/create-react-app/issues/11771 — committed to freesewing/freesewing by joostdecock 2 years ago
- set react-error-overlay to 6.0.9 in resolutions: https://github.com/facebook/create-react-app/issues/11771 — committed to Behodler/BehodlerUI by khazra 2 years ago
- set react-error-overlay to 6.0.9 in resolutions: https://github.com/facebook/create-react-app/issues/11771 — committed to Behodler/BehodlerUI by khazra 2 years ago
- react -> react-native: fix Web hot reloading meat [Uncaught ReferenceError: process is not defined](https://github.com/facebook/create-react-app/issues/11771) — committed to flyskywhy/PixelShapeRN by flyskywhy 2 years ago
- React使用详解.md: fix react-app-rewired Web hot reloading meat [Uncaught ReferenceError: process is not defined](https://github.com/facebook/create-react-app/issues/11771) ; fix react-app-rewired some... — committed to flyskywhy/g by flyskywhy 2 years ago
- chore: update react-scripts to v5 This updates react-scripts in the genreated starter app from create-app in order to resolve the react-error-overlay issue that was preventing hot reloading from work... — committed to DataDog/apps by deleted user 2 years ago
- chore: update react-scripts to v5 This updates react-scripts in the various starter apps in order to resolve an issue with hot reloading while working locally. References: - https://github.com/faceb... — committed to DataDog/apps by deleted user 2 years ago
- chore: update react-scripts to v5 This updates react-scripts in the various starter apps in order to resolve an issue with hot reloading while working locally. References: - https://github.com/faceb... — committed to DataDog/apps by deleted user 2 years ago
- chore: update to react v18 and react-scripts v5 (#126) This updates react-scripts in the various starter apps in order to resolve an issue with hot reloading while working locally. These changes i... — committed to DataDog/apps by ericrallen 2 years ago
- fix: hot module reload for react app throwing exception (#517) refer to github issue: https://github.com/facebook/create-react-app/issues/11771 — committed to web-infra-dev/modern.js by chenhuang444 2 years ago
Does ‘rm -rf node_modules’ and then npm/yarn install resolve the issue?
same here… Hot reload continues to work, but the page becomes unresponsive. Can’t click or do anything unless you do a manual refresh.
I see the same error with these dependencies.
node: 16.10.0 npm: 7.24.0 react-scripts: 5.0.0
Hot reload continues to work, but the page becomes unresponsive. Can’t click or do anything unless you do a manual refresh.
Is it fixed if updating to react-scripts v5?
I’m on CRA 4.0.3 and just as the last comment mentions in the end, adding react-error-overlay@6.0.9 to my devDependencies did not resolve the issues however adding as a resolution seems to work:
IMO while this is a total hack, it’s less fragile that modifying
yarn.lock
/package-lock.json
Another workaround for those who don’t want to update to
react-scripts@5.0.0
:"react-error-overlay": "6.0.9"
to yourpackage.json
node_modules
andpackage-lock.json
(don’t skip this step)The problem was that
react-scripts@4.0.3
does usereact-error-overlay@6.0.9
in its package.json. However, since6.0.10
is marked as a patch, npm does use v6.0.10 instead of v6.0.9. And Facebook, please… v6.0.10 does not compatible with v6.0.9Another (more dirty) workaround is to modify version of react-error-overlay in
package-lock.json
:I also had the same issue. It adds iframe overlay that’s why I was not able to click on page. Updating to react-scripts to 5.0.0 solved my issue.
This also happened for me sometimes. Whenever that happens and I inspect the page or any elements, everything is in an iframe containing javascript.
I had similar error after doing
npx rimraf ./**/node_modules
andnpm install
.The dependencies:
node: 14.17.1 npm: 6.14.13 react-scripts: 4.0.3
Solved after 2 hours. a mixed solution of @edub008 and @cchampou
You have to use
resolutions
and “react-error-overlay”: “6.0.9”`remember to delete node modules and package-lock.json
😄
A temporary fix was mentioned in #406940
Adding this to devDependancies seems to resolve the issue:
"react-error-overlay": "6.0.9",
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
This is probably working for yarn.
I have to do some other operation to make it effective also for npm:
1. Install npm-force-resolutions
npm i npm-force-resolutions
This helps to use the resolutions mechanism in npm.
2. Add the force resolutions preinstall script in package.json
"scripts": { "preinstall": "npx npm-force-resolutions" }
3. Now add the resolution
4. Delete package-lock.json
5. Delete node-modules
6. Install all packages again
npm install
I hope it helps!
CRA v5 now use the error overlay in webpack I think the process error is due to us updating the react-error-overlay package build to wp5 - so a regression we need to fix.
Cc @iansu
This is a possible solution Stackoverflow: Process not defined. You don’t have to touch any dependencies. Add this to App.js
useEffect(() => { window.process = { ...window.process, }; }, []);
In case you are using classes then use:
componentDidMount (){ window.process = { ...window.process } }
Having this same problem. Adding
"react-error-overlay": "6.0.9"
intodevDependencies
oroverrides
didn’t work, npm still decided to add version"6.0.10"
intopackage-lock.json
.However, using
yarn
with"resolutions": { "react-error-overlay": "6.0.9" }
fixed the problem.I also had this problem. Upgrading react scripts to 5.0.0 solved my problem. to upgrade react script : npm install react-scripts@5.0.0 .
Upgrading to v5 should solve the issue as v5 no longer use react-error-overlay - that said we have a regression in the react-error-overlay (as the build was updated to Webpack 5) - We aim to make a patch release soon fixing this issue.
Add the config below into the package.json. And it works. 🙏🏼
I was using CRA + CRACO + tailwind + tailwind/typography. Here’s what I did and it solved the issue for me:
So, does the CRA team have any plans to fix this bug in the future? Is the only way to solve it by adding it(resolutions) or upgrade v5 ?
setting it in
resolutions
ofpackage.json
didn’t work for me; i had to add it as an explicitdevDependencies
entry.Thanks a lot, this workaround is working fine.
This solution worked for me. Had to force it using
resolutions
field though. Thank you! (I’m using Yarn workspaces)Thanks, that does work, I realised I hadn’t manually specified the dependency in my projects requirements, but when I did manually it overridden the looser constraints on
react-dev-utils
.So React scripts 4.0.3 has a dependency on
"react-dev-utils": "^11.0.3",
which has the dependency on"react-error-overlay": "^6.0.9",
which matches6.0.10
. Maybe a React scripts 4.0.4 needs releasing with a fix for those stuck on v4?Still the same.
That guy found a solution, it worked for me !
https://github.com/facebook/create-react-app/issues/11880#issuecomment-1005409614
you guys using eslint?
For developers that can not fix it, there is a simple solution that can help you get rid o freezing situation
body > iframe[style*="2147483647"]:not([id="webpack-dev-server-client-overlay"]) { display: none; }
this helped me: Add this to package.json below the dependencies “resolutions”: { “react-error-overlay”: “6.0.9” }, Install react-error-overlay v6.0.9 inside your devDependencies.
@raix issue still remains. Adding react-error-overlay did not resolve.
it’s not helping me
i did that but now its giving me new error while doing npm start TypeError: match.loader.options.plugins is not a function btw im using craco to build the app any one knows what is happening?
react-error-overlay@6.0.9
unfreezes the UI, but the hot reload no longer kicks in at all for me.Must’ve been a cache / dependency issue for me, I used a stronger version of @mustkem 's suggestion (not sure if the ordering of these are technically correct):
yarn cache clean
rm -rf node_modules/ && rm yarn.lock
yarn install
npx yarn-upgrade-all
👈 https://www.npmjs.com/package/yarn-upgrade-allThis worked from my end.
I confirmed that the text displayed by the react-error-overlay library on the screen is the same as the error displayed on the terminal. So I temporarily used iframe { display: none } in reset.css.
I hope the bug is fixed. 🙏
I was able to resolve this by manually adjusting my
yarn.lock
file (😬):Before:
After:
Followed by
yarn install
to download the correct version (6.0.9).The immediate, working fix for this is likely to adjust
react-scripts
’spackage.json
to change"react-error-overlay": "^6.0.9"
to"react-error-overlay": "6.0.9"
.The longer-term, working fix for this is likely to revert
react-error-overlay@6.0.10
and re-publish it as7.0.0
.Added to dependencies and it works for me.
I just upgraded react-scripts to v5.0.0. It’s resolved
For those still having issues with this: If using Webpack, run
npm install -D dotenv-webpack
and if using typescriptnpm install -D @types/dotenv-webpack
.Then in your Webpack config, add
import Dotenv from "dotenv-webpack";
AndSee https://github.com/mrsteele/dotenv-webpack/blob/master/README.md After trying everything else, this finally worked for me.
sorry but I realized that this issue is currently showed as ‘Closed’, so I am just wondering if this issue will be addressed on CRA side in the future or we’ll need to manually fix it using the workaround mentioned above?
I believe resolutions property only works on Yarn 1 so won’t fix users of Yarn 2 or 3.
This bug came up because react-error-overlay published a breaking change with a patch semver instead of a major version bump.
Finally I figured out the issue. For me, the reason was because there was un caught exception. If you have such issue you have to check your terminal or CMD where you run your app.
The same issue occurred after upgrading to 5 version of webpack.
I’m facing the same issue. Let me know when you guys fix it please.
Per others on this thread, I made the following update to my package.json:
I then encountered a number of eslint errors. I added a missing
eslint-plugin-flowtype
package (that showed up in the new react-error-overlay). Based on a new error, I then needed to updateeslint-plugin-react-hooks
from v1 to v4 (link). Then, I learned thateslint
has also updated to v8, and needed to update typescript-related linting packages as well (link).In sum, I upgraded the following eslint-related packages.
I also encountered a
sass-loader
problem (project usesnode-sass
). Based on the following link, I deleted the boilerplate “font-family” line from App.scss, leftover from the original CRA project (link).I encountered this error earlier this week. I haven’t been able to find any explicit messages or threads dealing with webpack getting a breaking update in CRA projects. Hoping this helps!
Have you found a solution to this? This only started happening to me since I deleted and reinstalled all of my dependencies this morning.
No i am not using tailwind.
where you also using tailwind?