Replit.com no longer allows for the creation of .env files

It seems on Replit.com it’s no longer to create a .env file. Instead they ask you to put you configure your environment in the left sidebar in what looks to be called the ‘Secrets section’.

With the .env file my app worked as expected on Replit.com. I’m having issues getting the app to run correctly with these new ‘secrets’, however.

My app connects to MongoDB, and the functional tests pass, I then get a message that my Repl cannot be reached.

It seems the introduction of ‘secrets’ has just occured in the last few days so I can’t find any documentation on FCC to refer to. For that reason I thought I’d make a post for both myself and anyone else that may be struggling with this issue.

In my server.js and fcctesting.js files I tried to replace instances of process.env.PORT, and process.env.DB with my new ‘secret’ variables like PORT and DB, but my app still isn’t working correctly.

Any advice?

Project Link

GitHub Link (with original .env implementation)

3 Likes

I am still working to try to solve this issue. Here are two additional reference links I’ve gathered and read through.

The .env file has been deprecated on Replit.

Secrets and environmental variables.

Despite reading through these links, I still haven’t had any luck fixing the “Hmmmm… We couldn’t reach you repl” issue.

I will keep trying different things and update this thread if I find a solution.

1 Like

here, it’s pinned under #support

1 Like

Hey @ilenia, thank you for your response. As you can see from my image I have already added the key/value pairs as your link suggests.

Despite this, however, I am still running into the problems I mentioned above.

1 Like

I found the issue so I’m going to update this post just in case anyone else got stuck. It seems the boilerplate code includes the following line:

require("dotenv").config();

You need to remove this line as it attempts to load the environmental variables from a .env file (which we no longer have due to the introduction of REPLIT secrets). Hope someone finds this useful!

5 Likes

Very helpful , this helped me solve my issue in replit for which i was scratching my head for days :joy:

1 Like

where can I find this line to edit? I have checked in all the files of the project but cannot find it :frowning:

I apologize for the late reply (it’s been several weeks since I’ve logged into the forum). I’m pretty sure it’s in the server.js file, but it’s also possible they’ve updated the boilerplate code since my first post.

Good luck! :grinning:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.