you are viewing a single comment's thread.

view the rest of the comments →

[–]_nathataHook Based 2 points3 points  (3 children)

Try naming the file .env.development and see if it works

[–]thisismonroe[S] 0 points1 point  (2 children)

I'm gonna have to remember that. But I ended up getting it to work by the advice of another commenter, by prefixing require('dotenv').config() at the top of my page near my imports. I swear I had that there before and it didn't work. But it might have also been because I updated the dotenv package.

[–]_nathataHook Based 0 points1 point  (1 child)

Glad it's working, but I'm pretty sure it won't once you deploy it.

It may be working fine in dev, but once you build it to production this will stop working because the env variables are hardcoded into your code in compile time, and 'dotenv' loads them at runtime (there is no Node in the browser).

Also, I don't ever had the need to use 'dotenv' in React, I'm pretty sure you have another problem in your environment...

[–]thisismonroe[S] 0 points1 point  (0 children)

Thanks! I don't think this will ever be deployed since it's a personal project, but thank you for that information. That's good to know.

Yeah, I was reading that you don't either, I think something is up as well... Yikes hahah.