dotenv-safe icon indicating copy to clipboard operation
dotenv-safe copied to clipboard

Option allowEmptyValues set to true is not working

Open Yosr-Ch opened this issue 5 years ago • 2 comments

node version: v10.20.1 dotenv-safe version: 8.2.0 I set the allowEmptyValues to true but I'm still getting the MissingEnvVarsError. Here is my code:

require('dotenv-safe').config({
  allowEmptyValues: true,
  path: path.join(__dirname, '../../.env'),
  example: path.join(__dirname, '../../.env.example'),
});

I couldn't figure out what I'm missing here. Thank you for your help!

Yosr-Ch avatar Jun 17 '20 12:06 Yosr-Ch

same issue here, the allowEmptyValues set to true does nothing.

akrizs avatar Aug 31 '20 14:08 akrizs

@Yosr-Ch @antonedvard

If you have an .env.example file and .env file as mentioned below it will even throw an error with the allowEmptyValues as true if that is your case this will help.

# .env.example, committed to repo
SECRET=
TOKEN=
KEY=
# .env, private
SECRET=topsecret
TOKEN=

The allowEmptyValues just allows to have an empty value in the .env file but does not allow to skip a key in the .env file.

So the .env file should look like this to work with allowEmptyValues: true

# .env, private
SECRET=topsecret
TOKEN=
KEY=

jehincastic avatar Oct 31 '20 19:10 jehincastic