Ask coding questions

← Back to all posts
.env not working in Node js
thethermometer (3)


I'm trying to access some credentials from a .env file in a Node js repl, and it doesn't work.
I've used process.env.VARIABLE1 and my .env file looks something like:


And it just doesn't work. I know I have the right credentials, because it worked without the .env file...

Can someone help me out?

notGilbert (79)

youll need to


since .env support does not come with Node

thethermometer (3)

@notGilbert okay to I need to install it?

notGilbert (79)

@thethermometer yes, replit will automatically install it if it sees that you required it

2plus2is4hoi (94)

Well Idk how node works but if you could take the results of the file and search it for VARIABLE1, then set something to the next few characters it could work