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.

optionally change the file name of ".env"

See original GitHub issue

I have a complex set of environments which meant simultaneously having multiple .env.staging / .env.development / .env.development2 etc.

I would like to the ability to optionally override the file which you load env.

    _loadEnv: function(fileName) {
       if (!fileName) {
             fileName = ".env"
      }
      return dotenv._getKeysAndValuesFromEnvFilePath(fileName);
    },

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
LagomarsinoHScommented, Apr 23, 2021

sorry for revive this trend but my question is: can i name a .env file differently? like idk, environmentFile and then how can i call it? just dotenv.config({path:“rute/to/environmentFile”})

Thank u

3reactions
tianhuilcommented, Jul 10, 2019

You can set it either in javascript via

require('dotenv').config({ path: '/full/custom/path/to/your/.env' })

or by passing it through the command line

DOTENV_CONFIG_PATH=/full/custom/path/to/your/.env node -r dotenv/config your_script.js

Both examples are documented in the README.md

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bash - optionally set env var in command substitution
Set the timezone only when there's a parameter. You can do that by exporting $TZ inside the subshell whose output you're capturing.
Read more >
Env Variable Operators - yq - GitBook
To replace environment variables across all values in a document, envsubst can be used with the recursive descent operator as follows: yq '(....
Read more >
Customizing the environment variables file for the IBM HTTP ...
Start of change When you install the IBM® HTTP Server - Powered by Apache, the environment variables file, bin/envvars, is created.
Read more >
Linux environment variable tips and tricks | Enable Sysadmin
To make permanent changes to the environment variables for all new accounts, go to your /etc/skel files, such as .bashrc , and change...
Read more >
Declare default environment variables in file
The following syntax rules apply to environment files: Each line represents a key-value pair. Values can optionally be quoted.
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