question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Is the express .env exercise correct?

See original GitHub issue

Description

Extract from the exercise:

The .env file is a hidden file that is used to pass environment variables to your application. ā€¦

Link to the exercise.

We write a .env file holding a VAR=something. We can console log this variable, by running ā€œRunā€ in a repl.it file.

But this is not the standard Node.js behavior. npm start or node server.js wonā€™t load any variable unless we include the dotenv package. So If any user tries to emulate that project locally, it wonā€™t work the same.

I may be missing something simple, but just find it strange, and asking in repl.it didnā€™t help much so far.

Add a Link to the page with the problem:

Because itā€™s a hidden file the only way is to build it yourself. A way is to create a new repl.it and a .env file, then console logging the value.

Directory Tree Image

fcc-dotenv

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:32 (26 by maintainers)

github_iconTop GitHub Comments

2reactions
naomi-lgbtcommented, Oct 2, 2020

@RandellDawson I think thatā€™s probably the best approach. šŸ™‚

2reactions
TAbhaycommented, Oct 2, 2020

Just do

  1. npm install dotenv
  2. Add require(ā€˜dotenvā€™).config() in myApp.js file
  3. Add .env file with PORT = 3000
  4. Now npm start It will work
Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with passing the .env exercise on Basic Node and ...
I think there is a problem with the package fcc-express-bground, specifically in the index.js file. Can anyone help with this please!!. YourĀ ...
Read more >
How to set Environment Variable in node js? | Thirdock Techkno
Working with environment variables is a great way to configure different aspects of your Node.js application.
Read more >
Introduction to Node & Express - Medium
Node is a JavaScript environment built on the same JavaScript engine ... This post series has companion videos and exercises for members ofĀ ......
Read more >
How to setup Express.js in Node.js - Robin Wieruch
env file on your web server which is serving your application then. Exercises: Confirm your source code for the last section. Define forĀ ......
Read more >
Environment variables(.env) in node js express - Stack Overflow
env file which has all the environment related configuration which is necessary for the application. The purpose of .env is it varies for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found