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

Environmental variables from .env file are not loaded when jest test is launched in debug mode on chrome dev tools

I work on a vue.js app, which is tested with jest. To debug those tests I used this command node --inspect-brk node_modules/.bin/jest --runInBand --config test/jest.config.js and everything worked fine in chrome dev tools. Later we introduced some…
Adomas
  • 466
  • 1
  • 8
  • 21
0
votes
2 answers

Can you assign multiple Params in a variable in a .env file?

I want to create a new variable and use 2 parameters in it. How can I do that? I have newPerson as the variable. The variable should contain a userid and password. Can anyone help?
0
votes
1 answer

Why is pip installing dotenv?

Below is a shell session demonstrating the following steps: Create and enter a virtual environment Confirm that dotenv is not available to Python Confirm that dotenv is not in requirements.txt Install packages using pip install -r…
Chuck
  • 4,662
  • 2
  • 33
  • 55
0
votes
1 answer

Two .env environments with different passwords

In my app, I am using two API's that require different credentials. I am storing each in a .env file and read them using process.env. Both .env and .config files are in different directories. The first config.js: const dotenv =…
Chen
  • 860
  • 10
  • 32
0
votes
2 answers

How to generically update an existing environment variable to .env file?

I am using dotenv to load env variables and use in my mocha test. But based on a function that is generating a new token value for one of the existing environment var, I want to be able to generically update its value to .env file. Is it…
anonymous-explorer
  • 365
  • 1
  • 12
  • 26
0
votes
3 answers

How do I call a Node/Express API key (.env) in Client-side Javascript?

Right now I am using an OpenWeatherMap API key in my client side javascript for a simple weather app (Node/Express). I know this is not ideal outside of development, so I did npm install dotenv. On the server side, I can get and set the env…
K2SO Ghost Spirit
  • 1,291
  • 3
  • 11
  • 11
0
votes
0 answers

Should I keep requiring dotenv npm module in the app.js source file before deploying to Heroku?

I know that we must not commit the .env file to Heroku by adding the .env file to .gitignore but should I keep this line of code in the app.js source file? require("dotenv").config(); Or should be delete this line before git pushing? I have another…
0
votes
3 answers

.env shows incorrect values

So I have a file named .env with the following contents NODE_PATH=./src NODE_ENV=what TEST=test And I am calling that in my index.js in my react app. require("dotenv").config(); console.log(process.env); ... shows the following output NODE_ENV:…
Snoopy
  • 1,257
  • 2
  • 19
  • 32
0
votes
1 answer

Dotenv process.env keys are not accessible until I make a copy of the object

I'm adding .env to my Node Express app and when I do: console.log(process.env) I see some default process env variables which I didn't add, and also the one custom variable I've added to my .env file (TEST_VAR): { …
LennonR
  • 1,433
  • 18
  • 35
0
votes
1 answer

DOTENV not reading variables properly

This is my file: postgresU="myuser" postgresP="mypass" postgresH="myhost" postgresDB="mydb" postgresC="postgres://${postgresU}:{$postgresP}@{$postgresH}:5432/${postgresDB}" In my nodejs app, require('dotenv').config(); var connectionString =…
0
votes
1 answer

Difference between export SOME_ENV_VAR=KEY and SOMEOTHER_ENV_VAR=KEY in dotenv?

I am relatively new to Node.js. I want to export environment variables from .env file to my javascript files. In order to do that I am using dotenv. Which method should I use to export the environment variables to my main javascript files ( say-…
Ashish Gupta
  • 65
  • 1
  • 8
-1
votes
0 answers

After using my express server once it fails even though I have installed nodemon

The error i recieve the structure of my server file (all thos numbers are port numbers whihc is weird) This is description of my start server.js file I am trying to make a Node.js application using the Express framework to create a simple web…
-1
votes
1 answer

dfx deploy Error: [webpack-cli] Error: Cannot find module 'dotenv'

I was getting below error as I was using latest version of dfx dfx 0.14.3. After running dfx deploy on terminal getting below error. Error: Stderr: [webpack-cli] Failed to load '/home/navalega0109/ic-projects/dkeeper/webpack.config.js' config …
-1
votes
1 answer

How do I set my enviroment variables for create-react-app?

I have my create-react-app with Express running perfectly fine on localhost but now that I want to publish it I need to move some stuff to environment variables obviously. The thing is that I created my .env file in my /src folder (I can't move it…
Pizzaboy
  • 331
  • 2
  • 14
-1
votes
1 answer

How do I use dotenv with the tsx REPL for typescript?

When I run npx tsx, I get a REPL that lets me require modules like so: > const dotenv = require('dotenv'); > dotenv.config({ path: './config/env' }); // There's an index file in the env directory. The output of the above two commands is below: { …
mkelley33
  • 5,323
  • 10
  • 47
  • 71