Search code examples
reactjscreate-react-app

Uncaught ReferenceError: process is not defined (create-react-app 5.0.0)


I've migrated my react app to react-scripts 5.0.0 and now I get this error:

path.js:25 Uncaught ReferenceError: process is not defined
    at Object../node_modules/path/path.js (path.js:25:1)
    at Object.options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:61:1)
    at Object../node_modules/mime-types/index.js (index.js:16:1)
    at Object.options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:61:1)
    at Object../node_modules/react-s3-uploader/s3upload.js (s3upload.js:6:1)
    at Object.options.factory (react refresh:6:1)

That's the line from path.js:

var isWindows = process.platform === 'win32';

There's an issue on github https://github.com/facebook/create-react-app/issues/11773 that says such error caused by incorrect version of react-error-overlay but it seems that's no the case for me. I've tried every solution from this issue but the error is still there

$ npm why react-error-overlay                                                                                          [20:54:29]
[email protected]
node_modules/react-error-overlay
  dev react-error-overlay@"6.0.9" from the root project

Solution

  • downgrading react-scripts to 4.0.3 resolved my issue