Use the .env File secrets env replit

Tell us what’s happening:

I have problem with complete this challenge because now we use secrets in repl it and all ok, but when i test and i press button to check this challenge happen error!. In other forums provide solution use secrets in place of .env, convert env in String but i try it, it doesn’t happen.

Your project link(s)


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0

Challenge: Use the .env File

Link to the challenge:

How to Load Environment Variables from a .env File in Node.js (

const dotenv = require("dotenv")


you don’t need to conver to string

your issue is a logic flow one, you are getting the value of the environment variable when the app is created, instead of getting the value when the endpoint is called, so you never get a changed value

Same fail

I fix my before error and try other time with secrets and fail

what is it that is failing?

loading .env file:
boilerplate-express-1 - Replit

The tests

The .env file don’t work because repl-it remove this feature and change it to the secrets and the shell of repl it doesn’t allow make the file .env or in the GUI

Maybe I’m missing something, but how do these parts actually send the required response:

  let response = {"message": ""};
  let msg = "Hello json";


  response["message"] = msg;


The response object should either be {"message": "Hello json"} or {"message": "HELLO JSON"}, but this doesn’t set msg to be an object.

Open up the secrets tab (lock icon)and place the key(MESSAGE_STYLE) and value(uppercase)
inside and click add new secret.

1 Like

ahahaha thanks the solution it was change message to response

1 Like

Hey there, if you have any question about your code please create your own topic

I don’t understand why my solution is not working either…?
When I point to the /json endpoint, the object served appears to change depending on the .env variable.
The FCC test tells me otherwise!
Can anyone tell me what is wrong with my code please?

If you have a question about your own code, please create your own topic. Thanks.

1 Like

I had the same problem… And in case anyone found this thread through google, the solution was to put the

1 Like