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
22
votes
1 answer

When are quotes needed in .env file?

For instance, Symfony's configuring-environment-variables-in-env-files documents provides examples: DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name" DB_USER=root Why are quotes (aka parentheses) used for the first example and not…
user1032531
  • 24,767
  • 68
  • 217
  • 387
18
votes
1 answer

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. when trying to install dotenv

I'm trying to install dotenv for my discord bot with pip3 install dotenv but it keeps giving me this error: ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] =…
F.M
  • 1,369
  • 1
  • 16
  • 31
18
votes
5 answers

Why are my custom process.env not working within dotenv?

Learning that it is a bad practice to include API secret keys I've done some research and trying to learn how to create custom process.env. After reading: Node.js Everywhere with Environment Variables! How to set NODE_ENV to production/development…
DᴀʀᴛʜVᴀᴅᴇʀ
  • 7,681
  • 17
  • 73
  • 127
17
votes
2 answers

What is an .env (or dotenv) file exactly?

There's a lot of programs out there that can utilize .env files. Most of them support the basic bash-syntax, others support more advanced things like templating within the .env files. The way you're supposed to use .env files varies a lot as well.…
Bastian Venthur
  • 12,515
  • 5
  • 44
  • 78
17
votes
5 answers

Why i should not use dotenv in production mode?

Why I should not use dotenv in production mode ? I saw the following code on some websites. But I did not understand why they are doing this condition check. if (process.env.NODE_ENV !== 'production') { …
Avinash
  • 275
  • 1
  • 4
  • 12
17
votes
1 answer

Change Environment Variables Saved In .env File With Python and dotenv

I am trying to update .env environment variables with python. With os.environ I am able to view and change local environment variables, but I want to change the .env file. Using python-dotenv I can load .env entries into local environment…
Dylan Riley
  • 409
  • 1
  • 4
  • 14
17
votes
4 answers

Should I call dotenv in every node JS file?

I want to work with environment variables. Unfortunately, I am an inexperienced developer and decided very late to implement such a solution in my project. I'm trying to inject environment variables, located in .env file, to all JS files (not all of…
simplecreator
  • 393
  • 1
  • 2
  • 10
17
votes
3 answers

Using dotenv files with Spring Boot

I'd like to use dotenv files to configure my Spring Boot application. What is the best way to do this? In Ruby or Node world, I just creating .env file and it loads all stuff from there to application environment. I don't like to create separate…
Vova Rozhkov
  • 1,582
  • 2
  • 19
  • 27
16
votes
5 answers

Knex Heroku Error: self signed certificate

I keep getting this error: Error: self signed certificate When running this command in the terminal: knex migrate:latest --env production My knexfile.js require('dotenv').config(); module.exports = { development: { client:…
dfrancese
  • 201
  • 2
  • 4
15
votes
2 answers

In VS Code-debugger, how do I use envFile in launch.json for nodejs?

I'm trying to run the debugger in VS Code on my nodejs application. I'm using an .env file to store environment variables that I later call with process.env.. When I looked up the VS Code docs for the launch.json, it mentions the envFile option to…
14
votes
3 answers

JWT: Argument of type 'string | undefined' is not assignable to parameter of type 'Secret'

I'm using dotenv to declare JWT_SECRET env variable and It's showing the error mentioned in title. .env NODE_ENV="development" JWT_SECRET="mySecretString" environment.d.ts import { Secret } from 'jwt-promisify' declare global { namespace…
Swapnil Soni
  • 965
  • 1
  • 10
  • 26
14
votes
4 answers

Can't use dotenv with ES6 modules

I am moving an Express app across from CommonJS require syntax to the ES6 module import syntax. This is fine until I try and use dotenv to load my environment variables and every time I try to access these variables they come back as…
David Mulholland
  • 139
  • 1
  • 1
  • 4
14
votes
2 answers

How do I solve error "dotenv installation error" on pycharm

I am trying to install dotenv package on pycharm edu,but keep getting error that reads "AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader' " I tried to solve this using the python terminal by running command "pip…
Kutlwano Drew
  • 151
  • 1
  • 1
  • 6
13
votes
1 answer

Replace env variables in the .npmrc with dotenv before `npm install`

I have to work with some packages in the private registry. So, in my package.json in the dependencies section I have a lines like this one: ... "dependencies": { "@myco/my-awesome-package": "^0.4.5", ... } ... There is authentication…
Ceridan
  • 2,376
  • 3
  • 23
  • 32
12
votes
1 answer

nextJS how to load an environment variable properly

I am used to React and recently moved to NextJs, but facing a weird scenario. Having this Demo component rendered in a demo page; import React from 'react'; import { Hello, Header } from './demo.styled'; export const Demo = () => { const name =…
gxmad
  • 1,650
  • 4
  • 23
  • 29
1
2
3
54 55