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
12
votes
2 answers

FileNotFoundError with flutter_dotenv

I installed flutter_dotenv with this command: flutter pub add flutter_dotenv My is pubspec.yaml is like: dependencies: flutter: flutter_dotenv: ^5.0.0 flutter: assets: - .env Then I put .env file in the project root (I will use…
ASH
  • 459
  • 5
  • 18
12
votes
4 answers

How do I store my private api key on Vue.js app?

I read the documentation on Vue CLI and I wanted to make sure if I understand it correctly. The documentation says, Note that only NODE_ENV, BASE_URL, and variables that start with VUE_APP_ will be statically embedded into the client bundle with…
goodonion
  • 1,401
  • 13
  • 25
12
votes
3 answers

How do I use .env in Django?

My goal is to email using Python Django without having my email password being shown in the actual code. After some research, I guess I can store my password in an .env file and then access the password from the .env file. So, I currently have an…
usernaame001
  • 129
  • 1
  • 1
  • 9
12
votes
2 answers

how to use .env.qa or .env.staging with create react app

The CreateReactApp documentation shows that you can use a limited number of .env files. https://create-react-app.dev/docs/adding-custom-environment-variables/#adding-development-environment-variables-in-env I want to use more .env files for other…
cyrf
  • 5,127
  • 6
  • 25
  • 42
12
votes
2 answers

Symfony 4 Dotenv escape special characters

I use a password with a special char and symfony return an error "Malformed parameter "url"." How can i use this kind of password ? foo?bar I try with variables like…
n44s
  • 443
  • 4
  • 18
12
votes
5 answers

dotenv values not loaded in nextjs

I am struggling to load my .env file in my NextJS app. Here is my code: My .env is in root / My index.js is in /pages/index.js Here is my index.js: require("dotenv").config({ path: __dirname + '/../.env' }) import React, {Component} from…
Ellery Leung
  • 617
  • 3
  • 10
  • 23
11
votes
5 answers

Module not found: Error: Can't resolve 'fs' in dotenv/lib

All of a sudden, when creating a react production build, I get this error. > safe-courier@0.1.0 build > react-scripts build Creating an optimized production build... Failed to compile. Module not found: Error: Can't resolve 'fs' in…
Kally
  • 324
  • 1
  • 4
  • 12
11
votes
4 answers

I have installed python-dotenv but python cannot find it

i am using dotenv in a flask project, and have also tested this in a dumbed down test environment as well. I have tried uninstalling and reinstalling etc but the dotenv module cannot be found by python. When starting flask it sees there are some…
Mark Kortink
  • 1,770
  • 4
  • 21
  • 36
10
votes
4 answers

How to load environment variables in Svelte using Vite or Svite

I've been trying to figure out best practices on implementing environment variables for API configurations in Svelte App. As far as I know, We have to use either Vite or Svite to make it work. Can anyone help me find a solution please ??
Ben
  • 395
  • 1
  • 5
  • 16
10
votes
12 answers

NestJS setup TypeOrm connection with .env and @nestjs/config

I'm trying to find the most legal way to set up NestJS database using .env file. That is I want to use @nestjs/config package for importing .env variables and use them in the TypeOrmModule. It seems I need to use TypeOrmModule.forRootAsync. I'm…
Kasheftin
  • 7,509
  • 11
  • 41
  • 68
10
votes
3 answers

How to set file association to custom .env filename in VSCode settings?

I have a .envDEV file name that I use for development environment variables. And VSCode is not recognizing it as a dotenv file. If I change the language mode for the file, it seems to work (the proper styles are applied, 'though the icon won't…
9
votes
1 answer

Can you use dotenv in electron production?

I'm building an Electron, React app where I'm in need of a dotenv file. In code, I call my variables with process.env.variable which works fine in development. However, once distributed with electron-builder, the dotenv variables no longer work…
Scorpia
  • 375
  • 4
  • 15
9
votes
2 answers

How to load .env file for different environments in python?

I have three .env files for local, dev and prod environment and I have to load specific environments file while doing deployment for that server i.e If am doing DEV deployment then dev .env file should load all.
Nitesh Soomani
  • 572
  • 5
  • 12
9
votes
3 answers

How can I load environment variables with ts-node?

I've tried a few implementations which none have been successful. First Attempt Using eval in package.json script "fetch:data": "eval $(cat .env) ts-node -O '{\"module\":\"commonjs\"}' ./bin/build-api-data.ts". This results in a JSON parsing error…
jango
  • 133
  • 1
  • 1
  • 5
9
votes
6 answers

NodeJS not recognizing .env file

I have like 5 NodeJS services running, but I have a problem in one of those. This is the nodemon.json file: { "watch": ["**/*.ts"], "ext": "ts,json", "ignore": ["./test/*.ts"], "exec": "node -r ts-node/register -r dotenv/config Index.ts…
pmiranda
  • 7,602
  • 14
  • 72
  • 155
1 2
3
54 55