Questions tagged [dotenv]

This tag is for questions about the Dotenv Node.js module. For PHP, see the `phpdotenv` tag; for ruby, see the `ruby-dotenv` tag.

Dotenv is a zero-dependency Node.js module that loads environment variables from a .env file into process.env. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.

Find NPM package here for documentaion.

Other language implementations

821 questions
9
votes
3 answers

require('dotenv').config() in node.js

In my node.js application, I have a require('dotenv').config(); line that I need when developing locally in order to use environment variables. When I deploy to AWS however, I need to comment out this line, otherwise the application crashes.…
user11508332
  • 537
  • 1
  • 11
  • 28
9
votes
2 answers

I have node.js application I am setting .env using dotenv, I get the following error when using port

I have node.js application I have installed dotenv and add the following configuration in my .env file DB_HOST='localhost' DB_Database=TheDatabasename DB_USER=TheUser DB_PASS=thePassword DB_PORT=1433 I am using sqlserver I call dotenv like…
MJ X
  • 8,506
  • 12
  • 74
  • 99
8
votes
6 answers

Environment Variable not loading with load_dotenv() in Linux

I'm trying to make a discord bot, and when I try to load a .env with load_dotenv() it doesn't work because it says Traceback (most recent call last): File "/home/fanjin/Documents/Python Projects/Discord Bot/bot.py", line 15, in
F.M
  • 1,369
  • 1
  • 16
  • 31
8
votes
2 answers

Unable to install dotenv on Windows

I never thought I'd be using Stack Overflow, but here I am! I am unable to install DotEnv on Windows, when I execute pip install dotenv with its optional flags, this error is thrown: Collecting dotenv Using cached dotenv-0.0.5.tar.gz (2.4 kB) …
8
votes
2 answers

Jest doesn't load environment variables (even with --setupFiles dotenv/config)

I'm writing tests for my Express project, but when I run the test script my environment variables are not loaded. In other threads people suggested using --setupFiles dotenv/config, which I did, but unfortunately it didn't work. I tried both adding…
Allan Juan
  • 2,048
  • 1
  • 18
  • 42
8
votes
2 answers

Why is process.env undefined in module?

I'm beginner with nodejs and I want environment variables shared through modules. I read those variables with dotenv package. But in next required module process.env is…
oLDo
  • 487
  • 1
  • 3
  • 15
8
votes
1 answer

using interpolation in .env files

I'm trying to use a .env file in a node app and dotenv NPM module to read it, but use some variables and interpolation. what works in a standard bash file doesn't seem to run within a .env config file though. e.g.,…
dcsan
  • 11,333
  • 15
  • 77
  • 118
8
votes
2 answers

Preload the env file from custom path

I am trying to preload the .env file when the node application starts. I have the following configuration but whenever I run npm run start:dev i get error. "scripts": { "lint": "tslint --project tsconfig.json", "build": "tsc", …
niklodeon
  • 1,320
  • 5
  • 20
  • 51
8
votes
4 answers

Dotenv-webpack in production?

I am trying to use the dotenv-webpack plugin. This works great locally. But fails when I deploy to Heroku. I have followed advice according to this git issue, but still am having issues. My webpack config looks like this: const path =…
sWarren
  • 473
  • 2
  • 4
  • 10
8
votes
3 answers

Does dotenv contradict the Twelve-Factor App?

I have read about the Twelve Factor App's Config - Section III and searched for a way to do it in NodeJS. It seems that most people recommend dotenv to store configs in environment variables. However, it seems that dotenv contradicts the…
StevenDaGee
  • 127
  • 1
  • 6
8
votes
1 answer

Why dotenv files should not be checked in?

I'm new to nodejs, so forgive me if my question is too trivial. I'm creating an enviornment files using dotenv. However, on their WebSite, they recommend against checking in .env file. So, I was wondering if this files is not checked in , how…
ANewGuyInTown
  • 5,957
  • 5
  • 33
  • 45
7
votes
3 answers

How to use different environments with `.env` files in NodeJs

I am currently building a backend in nodejs. I am thinking about how to add an environment configuration to the project. My idea is that I have a /config folder in which I have my envparser.ts (have to think about a better name for this ^^) which…
Masdot
  • 90
  • 1
  • 7
7
votes
2 answers

How can we store a JSON credential to ENV variable in python?

{ "type": "service_account", "project_id": "project_id", "private_key_id": "private_key_id", "private_key": "-----BEGIN PRIVATE KEY-----\n", "client_email": "email", "client_id": "id", "auth_uri": "uri_auth", …
Subham
  • 160
  • 2
  • 10
7
votes
4 answers

Playwright tests - using variable from .env file

I've got Playwright test written using TypeScript and I would like to use variables from .env in my test file, how can I do that?
MichalG
  • 221
  • 1
  • 4
  • 11
7
votes
1 answer

Production ENV file with docker/build-push-action and GitHub Actions

I have the following docker/build-push-action job that runs in my GitHub actions when a release tag is created. jobs: docker: runs-on: ubuntu-latest steps: - name: Set up QEMU uses: docker/setup-qemu-action@v1 …