Use the .env File: Do not know why test fails

Tell us what’s happening:
The result seems to be what is needed, but the tests do not pass and I do not get why.


Your project link(s)

Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36.

Challenge: Use the .env File

Link to the challenge:

Hello there,

This looks related: Use the .env File - Issue [RESOLVED] - freeCodeCamp Support - The freeCodeCamp Forum

I suggest you follow the instructions to update the package.

Hope this helps

Thanks for your help. Done that. Unfortunately it still does not work.

Do you have a file named sample.env? I had this same problem and had to create a new file called .env and then it worked. It would be easier if you had a link to your code that we can look at

Hey again. This is a small typo:

let response = "Hello Json";

Go to the previous lesson to see what it should be.

Hope this helps

Ouch! I am sorry for not seeing the typo. Corrected it. Unfortunately the test still does not pass. I am helpless … :frowning:

The file is called .env.

This is my code:

var express = require('express');
var app = express();

console.log("Hello Express");
app.use("/public", express.static(__dirname + "/public"));
app.get("/", function(req, res) {
  res.sendFile(__dirname + "/views/index.html");
app.get("/json", function(req, res) {
    let response = "Hello json";
    if (process.env.MESSAGE_STYLE=="uppercase") {
      response = response.toUpperCase();
    res.json({"message":  response});

 module.exports = app;

This is the code in the .env-file:


Really… After fixing that, I managed to pass with everything else the same.

I feel pretty awkward here. To show what I am doing here is a recording.

Thank you, for the video. Unfortunately, I see no reason for it to fail, and I am still able to pass with your app link.

Would you mind trying to submit again, and open the browser devtools, as you submit. See if any specific errors appear (on the page)

I do not see any changes in the developer console when I submit it. Can I simply skip this challenge? Or use another person’s solution?

Yes, sure. You got the correct answer :+1: Well done, for going through the hassle. Hopefully, you learnt something more out of it.

1 Like

This might sound weird, but you might have been trying to submitting link on the wrong page. Challenge page on video was for one challenge before the .env one.

Using your link .env challenge is passing for me too. Challenge before it isn’t passing, what is expected at that point, as .env file makes json response capitalized.


Holy! You are right. I am really sorry for consuming valuable community time for such simple problems. But thanks a lot anyway. I have learned that I need to be much more accurate than I seem to be.

1 Like

It’s fine. It’s actually common mind behavior, when being stuck at something for a while, to omit seemingly obvious solutions, because mind is too busy with finding deeper, more complicated reasons.

1 Like

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