Tell us what’s happening:
I have created the .env file, but when I try to access the variable from the .env file in my code after running the app.js file its response that the variable is undefined
code for .env and app.js
.env file MESSAGE_STYLE=uppercase
As Ieahleen said, it is easier to help, if you provide the link to your project code. Keep in mind, we cannot see what is in your .env file (default Replit). So, you will have to paste it here for us to look at.
When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
I have added the code for sending HELLO JSON in the post. But the issue is when I try to access the process.env.MESSAGE_STYLE variable it gives undefined
That error comes from the custom logger written in the fcc-bground-express package. It looks like either:
a) The package did not install correctly
b) You are using an outdated version of the package (old boilerplate?)
For Replit, dotenv is not required - included out of the box.
EDIT: To add, you are not required to log the value of anything within the .env file. So, whilst it is good to check things like this, I suggest you move on without doing so.