# .env file for node

**URL:** <https://forum.freecodecamp.org/t/env-file-for-node/208534>\
**Category:** General\
**Created:** [July 13, 2018, 4:40pm UTC](https://forum.freecodecamp.org/t/env-file-for-node/208534 "2018-07-13T16:40:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sampersondmm](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@sampersondmm](https://forum.freecodecamp.org/u/sampersondmm)\
**Post date:** [July 13, 2018, 4:40pm UTC](https://forum.freecodecamp.org/t/env-file-for-node/208534/1 "2018-07-13T16:40:59Z")

</div>

Hello, I’m doing the node and express exercises and I’m stuck on the .env file. The goal is to write “Message\_Style=uppercase” in the file and then use that to change the api call from the previous exercise.  
I can’t think of what that really means though. Here’s my best guess:

app.get(’/’, function(req,res) {  
if(process.env.Message\_Style === ‘uppercase’){  
res.send({message: ‘HELLO JSON’);  
}  
else {  
res.send({message: ‘Hello json’});  
}

This works I guess but it won’t accept it as an answer. I only get “Unexpected token N in JSON at position 0” as an error.

---

<div class="post-metadata">

**Author:** ![shimphillip](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/shimphillip/32/158663_2.png) [@shimphillip](https://forum.freecodecamp.org/u/shimphillip)\
**Post date:** [July 13, 2018, 5:29pm UTC](https://forum.freecodecamp.org/t/env-file-for-node/208534/2 "2018-07-13T17:29:39Z")

</div>

how does your .env file look like?

---

<div class="post-metadata">

**Author:** ![sampersondmm](https://avatars.discourse-cdn.com/v4/letter/s/8491ac/32.png) [@sampersondmm](https://forum.freecodecamp.org/u/sampersondmm)\
**Post date:** [July 13, 2018, 5:41pm UTC](https://forum.freecodecamp.org/t/env-file-for-node/208534/3 "2018-07-13T17:41:52Z")

</div>

```auto
# Environment Config

# store your secrets and config variables in here
# only invited collaborators will be able to see your .env values

# reference these in your code with process.env.SECRET

SECRET=
MADE_WITH=
MESSAGE_STYLE=uppercase

# note: .env is a shell file so there can't be spaces around =

```

---

<div class="post-metadata">

**Author:** ![kevinSmith](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevinsmith/32/72934_2.png) [@kevinSmith](https://forum.freecodecamp.org/u/kevinSmith)\
**Post date:** [July 13, 2018, 5:51pm UTC](https://forum.freecodecamp.org/t/env-file-for-node/208534/4 "2018-07-13T17:51:28Z")

</div>

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See [this post](http://forum.freecodecamp.com/t/forum-code-formatting/25574) to find the backtick on your keyboard. The “preformatted text” tool in the editor (`</>`) will also add backticks around text.

![markdown_Forums](https://sea3.discourse-cdn.com/freecodecamp/uploads/default/original/3X/4/b/4b9a26f0c243380dd84935f4e29b92e3ecee8d05.gif)

---

<div class="post-metadata">

**Author:** ![shimphillip](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/shimphillip/32/158663_2.png) [@shimphillip](https://forum.freecodecamp.org/u/shimphillip)\
**Post date:** [July 13, 2018, 6:10pm UTC](https://forum.freecodecamp.org/t/env-file-for-node/208534/5 "2018-07-13T18:10:59Z")

</div>

I see the problem now.

> Then tell the GET /json route handler

You are not giving it a correct route.

---

<div class="post-metadata">

**Author:** ![Rem0ld](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/rem0ld/32/136548_2.png) [@Rem0ld](https://forum.freecodecamp.org/u/Rem0ld)\
**Post date:** [March 9, 2020, 9:11pm UTC](https://forum.freecodecamp.org/t/env-file-for-node/208534/6 "2020-03-09T21:11:53Z")

</div>

Hello,  
First you PATH is incorrect it should be `"/json"`

Then your variable should be in uppercase as in the .env file

```auto
process.env.MESSAGE_STYLE === ‘uppercase’

```

and finally you can use `"Hello json".toUpperCase()`

Hopefully this correction will help others…

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 11:28am UTC](https://forum.freecodecamp.org/t/env-file-for-node/208534/7 "2021-01-16T11:28:01Z")

</div>

Closed on January 16, 2021, 11:28am UTC


