# Basic Node and Express - Use the .env File

**URL:** <https://forum.freecodecamp.org/t/basic-node-and-express-use-the-env-file/593915>\
**Category:** Curriculum Help\
**Created:** [February 22, 2023, 10:21am UTC](https://forum.freecodecamp.org/t/basic-node-and-express-use-the-env-file/593915 "2023-02-22T10:21:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![borel](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/borel/32/237283_2.png) [@borel](https://forum.freecodecamp.org/u/borel)\
**Post date:** [February 22, 2023, 10:21am UTC](https://forum.freecodecamp.org/t/basic-node-and-express-use-the-env-file/593915/1 "2023-02-22T10:21:34Z")

</div>

If you are using Replit, you cannot create a .env file. Instead, use the built-in SECRETS tab to add the variable.//i don’t know to how to use built -in secrets tab with replit i need your help

---

<div class="post-metadata">

**Author:** ![igorgetmeabrain](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/igorgetmeabrain/32/314517_2.png) [@igorgetmeabrain](https://forum.freecodecamp.org/u/igorgetmeabrain)\
**Post date:** [February 22, 2023, 10:25am UTC](https://forum.freecodecamp.org/t/basic-node-and-express-use-the-env-file/593915/2 "2023-02-22T10:25:47Z")

</div>

![Untitled](https://global.discourse-cdn.com/freecodecamp/original/4X/e/6/6/e668d953c1dfdb2bff59850e4b29c4bd60344f99.png)  
It’s here in the Tools.  
Just enter MONGO\_URI in one field and your URI in the other and click ‘Add new secret’.  
Then you can access the variable as `process.env.MONGO_URI`.

---

<div class="post-metadata">

**Author:** ![borel](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/borel/32/237283_2.png) [@borel](https://forum.freecodecamp.org/u/borel)\
**Post date:** [February 22, 2023, 11:10am UTC](https://forum.freecodecamp.org/t/basic-node-and-express-use-the-env-file/593915/3 "2023-02-22T11:10:26Z")

</div>

If you are working locally, you will need the `dotenv` package. It loads environment variables from your `.env` file into `process.env` . The `dotenv` package has already been installed, and is in your project’s `package.json` file. At the top of your `myApp.js` file, add `require('dotenv').config()` to load the environment variables.

//  
.replit  
(‘dotenv’)  
.config()  
it will look like this??

---

<div class="post-metadata">

**Author:** ![hbar1st](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hbar1st/32/372649_2.png) [@hbar1st](https://forum.freecodecamp.org/u/hbar1st)\
**Post date:** [February 22, 2023, 11:11am UTC](https://forum.freecodecamp.org/t/basic-node-and-express-use-the-env-file/593915/4 "2023-02-22T11:11:51Z")

</div>

Are you using replit? Or are you working on your local files?

---

<div class="post-metadata">

**Author:** ![borel](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/borel/32/237283_2.png) [@borel](https://forum.freecodecamp.org/u/borel)\
**Post date:** [February 22, 2023, 12:47pm UTC](https://forum.freecodecamp.org/t/basic-node-and-express-use-the-env-file/593915/5 "2023-02-22T12:47:17Z")

</div>

i’m using replit but my code is not working

---

<div class="post-metadata">

**Author:** ![igorgetmeabrain](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/igorgetmeabrain/32/314517_2.png) [@igorgetmeabrain](https://forum.freecodecamp.org/u/igorgetmeabrain)\
**Post date:** [February 22, 2023, 1:31pm UTC](https://forum.freecodecamp.org/t/basic-node-and-express-use-the-env-file/593915/6 "2023-02-22T13:31:17Z")

</div>

Could you link to your code on replit please? (The url in the address bar when you’re on the repl).

---

<div class="post-metadata">

**Author:** ![camperextraordinaire](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@camperextraordinaire](https://forum.freecodecamp.org/u/camperextraordinaire)\
**Post date:** [February 22, 2023, 2:14pm UTC](https://forum.freecodecamp.org/t/basic-node-and-express-use-the-env-file/593915/7 "2023-02-22T14:14:59Z")

</div>

@borel You can use the same replit for all of the challenges within a section unless the instructions say otherwise. Most new curriculum sections start with a new starter boilerplate that you must use for that section.

As far as passing this challenge, your existing code in `https://replit.com/@bowak/boilerplate-express-13` will pass as long as you have added the correct environment variable (`MESSAGE_STYLE`) and value (`uppercase`) to the Secrets section.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [August 24, 2023, 2:15am UTC](https://forum.freecodecamp.org/t/basic-node-and-express-use-the-env-file/593915/8 "2023-08-24T02:15:30Z")

</div>

Closed on August 24, 2023, 2:15am UTC

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