I’m currently working on the APIs and Microservices certification - Basic Node and Express, to be more specific.
I’m using the Glitch platform to complete this project.
At the 6th challenge, in order to complete it, we need to modify the .env file. The problem is that I cannot find it, as you can see in the following picture.
The file exists (I console logged process.env and it returned all the key-values), but it is hidden.
Can you please point me to the right direction so I can successfully finish this challenge?
Hello and welcome to the FCC community~!
process.env will show you specific environment variables that are automatically generated (
PUBLIC_URL are a couple that come to mind). However, you will often need to create custom environment variables as well (such as API keys). To do this, you store them in a file called
The reason you do not see a
.env file when you clone the project is that
.env files should generally never be uploaded to GitHub. A
.env file is intended to hold secret environment variables that you would not want available publicly, and uploading the file to GitHub can allow others to see those values.
For this challenge, you will want to use the
New File option to manually create a
.env file and add the necessary key-value pair. Glitch, I believe, offers a GUI for managing environment variables (which you will see when you create the file) - alternatively, you can choose to view it as a text file and add the values manually with a
Glad to be here!
I’ve tried to create a new .env file but I couldn’t figure out how to link my project to this new file.
Eventually, I solved the problem by adding the following line in “myApp.js”:
process.env.MESSAGE_STYLE = "uppercase";
This adds a new variable to the already existing .env file without me having to actually open it.
Also, I found out later that by going to Tools > Logs > Debugger, the .env file finally shows up (offering, as you mentioned before, a GUI for managing the variables).