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.

new feature proposal: default value if var is not defined

See original GitHub issue

how can I make sure that if an environment variable is not defined(inside .env file) I can have a default value? example: assuming that the PORT variable is not specified in my .env file but I want to have a default value anyway:

require('dotenv').config({
  defaults: {
    PORT: 8080
  }
})

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
paramsiddharthcommented, Jul 19, 2021

Looks good! If approved, I would like to work on the issue.

0reactions
motdotlacommented, Jan 17, 2022

@tawfiek I think your team will like it. It makes it very easy to securely sync you .env files across your team’s many machines. So far everyone using it so far is really enjoying it. They say it is like using git - one of the first things they now reach for with their team.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ansible - Use default if a variable is not defined
I was wondering if there's a more flexible way to cope with default values. I know that the code below is possible: -...
Read more >
Allow optional attribute values to have dynamic default ...
I was sooo excited to finally use this new feature, but to my dismay I discovered that if you have e.g. flavor_name =...
Read more >
Default parameters - JavaScript - MDN Web Docs
Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.
Read more >
Allow default value for variables (&7437) · Epics · GitLab.org
Description. Allow variables defined global or on job level to have a default value as for example: Using the ${MY_VAR:default_value} ...
Read more >
value expressions - produce the default value for any type
Use the default value expressions to obtain the default, uninitialized value of a type. The default value expression can be used with ...
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