0

I'm trying to run a React application and when I load localhost I get a blank white page. I'm able to see the title but that's about it. When I look into the Console I receive this message:

Uncaught ReferenceError: process is not defined
    at config (main.js:56:1)
    at Module../src/utils/config.ts (config.ts:5:1)
    at Module.options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:61:1)
    at Module../src/utils/api.ts (reportWebVitals.ts:15:1)
    at Module.options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:61:1)
    at Module../src/utils/apiService.ts (api.ts:38:1)

When I click the main.js:56:1 line I'm shown there's an issue here:

let dotenvPath = path.resolve(process.cwd(), '.env')

Would this be accurate as to why the page is not loading, or is there something else I should be looking into?

Joundill
  • 6,828
  • 12
  • 36
  • 50
Ian
  • 1
  • 1
  • I suggest you take a look at this :https://stackoverflow.com/questions/70368760/react-uncaught-referenceerror-process-is-not-defined – Erfan Feb 10 '22 at 06:14
  • None of the suggested solutions in that link worked for me. – Ian Feb 10 '22 at 06:57
  • It looks like localhost is only showing index.html and nothing more. – Ian Feb 10 '22 at 07:21

1 Answers1

0

The process variable is only for Node.js and does not exist inside the browser, which is what you are using to view localhost. If you want to use this line, you will have to either set up a custom process variable in the webpage that contains a cwd function that returns a string, or use webpack.DefinePlugin to replace process.cwd() with a constant string like "C:/fakepath/to/file.env".

ErrorGamer2000
  • 295
  • 3
  • 8