Use the .env File will not pass

Tell us what’s happening:
I have been trying to pass this test for 3 days now with no luck, I’ve tried re working my solution a few times, but I think it may be more of an issue with FCC or Glitch… Here is the error I keep getting in the log, with the full print out below

  "Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client".


*

2:38 PM

*

2:38 PM

https://www.freecodecamp.org

2:39 PM

SyntaxError: Unexpected token < in JSON at position 0

2:39 PM

at JSON.parse (<anonymous>)

2:39 PM

at /rbd/pnpm-volume/f7c68ebc-3195-46e1-8add-b564851577db/node_modules/.github.com/freeCodeCamp/fcc-express-bground-pkg/597d66d2cc536e746e1603d0332246317d515f79/node_modules/fcc-express-bground/index.js:80:26

2:39 PM

at IncomingMessage.r.on (/rbd/pnpm-volume/f7c68ebc-3195-46e1-8add-b564851577db/node_modules/.github.com/freeCodeCamp/fcc-express-bground-pkg/597d66d2cc536e746e1603d0332246317d515f79/node_modules/fcc-express-bground/index.js:29:26)

2:39 PM

at IncomingMessage.emit (events.js:189:13)

2:39 PM

at IncomingMessage.Readable.read (_stream_readable.js:487:10)

2:39 PM

at flow (_stream_readable.js:953:34)

2:39 PM

at resume_ (_stream_readable.js:934:3)

2:39 PM

at process._tickCallback (internal/process/next_tick.js:63:19)

2:39 PM

SyntaxError: Unexpected token < in JSON at position 0

2:39 PM

at JSON.parse (<anonymous>)

2:39 PM

at /rbd/pnpm-volume/f7c68ebc-3195-46e1-8add-b564851577db/node_modules/.github.com/freeCodeCamp/fcc-express-bground-pkg/597d66d2cc536e746e1603d0332246317d515f79/node_modules/fcc-express-bground/index.js:88:28

2:39 PM

at IncomingMessage.r.on (/rbd/pnpm-volume/f7c68ebc-3195-46e1-8add-b564851577db/node_modules/.github.com/freeCodeCamp/fcc-express-bground-pkg/597d66d2cc536e746e1603d0332246317d515f79/node_modules/fcc-express-bground/index.js:29:26)

2:39 PM

at IncomingMessage.emit (events.js:189:13)

2:39 PM

at IncomingMessage.Readable.read (_stream_readable.js:487:10)

2:39 PM

at flow (_stream_readable.js:953:34)

2:39 PM

at resume_ (_stream_readable.js:934:3)

2:39 PM

at process._tickCallback (internal/process/next_tick.js:63:19)

2:39 PM

_http_outgoing.js:470

2:39 PM

throw new ERR_HTTP_HEADERS_SENT('set');

2:39 PM

^

2:39 PM

2:39 PM

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

2:39 PM

at ServerResponse.setHeader (_http_outgoing.js:470:11)

2:39 PM

at ServerResponse.header (/rbd/pnpm-volume/f7c68ebc-3195-46e1-8add-b564851577db/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/response.js:771:10)

2:39 PM

at ServerResponse.send (/rbd/pnpm-volume/f7c68ebc-3195-46e1-8add-b564851577db/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/response.js:170:12)

2:39 PM

at ServerResponse.json (/rbd/pnpm-volume/f7c68ebc-3195-46e1-8add-b564851577db/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/response.js:267:15)

2:39 PM

at /rbd/pnpm-volume/f7c68ebc-3195-46e1-8add-b564851577db/node_modules/.github.com/freeCodeCamp/fcc-express-bground-pkg/597d66d2cc536e746e1603d0332246317d515f79/node_modules/fcc-express-bground/index.js:97:15

2:39 PM

at IncomingMessage.r.on (/rbd/pnpm-volume/f7c68ebc-3195-46e1-8add-b564851577db/node_modules/.github.com/freeCodeCamp/fcc-express-bground-pkg/597d66d2cc536e746e1603d0332246317d515f79/node_modules/fcc-express-bground/index.js:29:26)

2:39 PM

at IncomingMessage.emit (events.js:189:13)

2:39 PM

at IncomingMessage.Readable.read (_stream_readable.js:487:10)

2:39 PM

at flow (_stream_readable.js:953:34)

2:39 PM

at resume_ (_stream_readable.js:934:3)

2:39 PM

4 minutes ago

Hello World

2:39 PM

Node is listening on port 3000...

2:39 PM

*

**Your code so far**
MESSAGE_STYLE=uppercase
Code in the .env page 

        Here is the code from myApp.js


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

// --> 7)  Mount the Logger middleware here

// --> 11)  Mount the body-parser middleware  here

/** 1) Meet the node console. */
console.log("Hello World");

/** 2) A first working Express Server */
// app.get("/",function(req, res) {
//   res.send('Hello Express');
// })

/** 3) Serve an HTML file */
app.get("/", (request, response) => response.sendFile(__dirname + "/views/index.html"));

/** 4) Serve static assets  */
app.use(express.static("public"));

/** 5) serve JSON on a specific route */
app.get("/json", function(req, res){
  res.json({"message": "Hello json"});
});

/** 6) Use the .env file to configure the app */
app.get("/json", function(req, res) {
  if (process.env.MESSAGE_STYLE === 'uppercase') {
    res.json({
      message:"HELLO JSON"
    });
  }
  res.json({message:"Hello json"});
});

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36.

Challenge: Use the .env File

Link to the challenge:

Hello there,

This is a known issue, and is being worked on. You can follow the issue here: https://github.com/freeCodeCamp/freeCodeCamp/issues/39095

Some work-arounds:

  1. Use CodeSandbox to fork the boilerplate, and complete it there.
  2. Use Repl.it to fork the boilerplate, and complete it there.

Hope this helps