Replit Create a .env File Changed

Recently, Replit have adjusted their editor to no longer allow .env files to be created. As such, in order to use environment variables, a new tab in the left pane has been added which looks like a lock :lock:

To add an environment variable, place the variable name in the key input, and the value in the value input.

3 Likes

@Sky020 I’d like to add another tip from my other thread for if you get the error “Hmmm… we couldn’t reach your repl”.

The boilerplate for many of the FCC projects 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). Once you remove this line your app should run correctly (given you followed the instructions above from @Sky020 correctly). Happy coding! :grinning:

4 Likes

thanks. for the suggestion

thanks for your suggestions and guide

plss help me now how to save our not token plss help me
bot.py token

add a Secret like in the first post

please I need someone’ help since I am exactly on that page of the course. I added the environmental variable with the if-else conditions and everything works correctly (infact i can see the message in uppercase in the myapp/json). However when I copy and paste the url for testing it does not pass the test . I have refreshed and restarted the app but with same poor result. What’s wrong?

If you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

i did, but nobody has given me an reply, so I am stuck :frowning:

Hi you’re probably gotten past this problem
Just want to share my code that passes the test here, to help out other campers

const response = "Hello json";
app.get("/json", (req, res) => {
  res.json({
    message: process.env.MESSAGE_STYLE === 'uppercase' ? response.toUpperCase() : response
  })
});
1 Like