3

I recently upgraded my react app - initially created with CRA, but i'm getting an error i can't figure out how to solve :

ERROR in ./node_modules/dotenv/lib/main.js 24:11-24

Module not found: Error: Can't resolve 'fs' in '/project/frontend-react/node_modules/dotenv/lib'

EDIT:

  • what am I doing to get this error : npm start
  • where do I get that error : in the browser, the app is not loading at all
  • and in regard to the error it's really all i'm getting

Any help welcome, as i'm lost despite quiet a lot of research...

Tibo
  • 621
  • 1
  • 8
  • 24
  • 1
    And _where_ is that error? Because neither `fs` nor `dotenv` have any business being in your bundle. They're server-side only. (and remember to [update your post](/help/how-to-ask) with that information. You've left out some important details atm: what are you doing to get that error, _where_ do you get that error, and what is the _exact_ error: errors are code, so always just show the exact code in code markup) – Mike 'Pomax' Kamermans Jan 11 '22 at 15:21
  • Mike : i updated the message – Tibo Jan 11 '22 at 16:01
  • But you may not have clicked the link to read the stackoverflow posting guidelines. `npm start` does not tell anyone what you're actually doing. What does that start? Also, you're still not showing the actual error, it's definitely longer than just that one line. You're also not talking about what ([mcve]) code you have that reproduces this problem, etc. I see you solved your own problem from your answer, but that's more a sign that it's probably a good idea to delete this post again: never bundle server code into a client app. All tutorials for webpack, react, etc. explain that aspect. – Mike 'Pomax' Kamermans Jan 11 '22 at 16:40
  • This might be useful to you, helped me solve my problem: https://stackoverflow.com/questions/42182577/is-it-possible-to-use-dotenv-in-a-react-project BR – Roslava Angelova Aug 03 '22 at 08:45

1 Answers1

1

Well, I was using dotenv on the app, removing it cleared the error...

Tibo
  • 621
  • 1
  • 8
  • 24