Closed ShahriarKh closed 1 year ago
Config path accepts any string. I tried:
dotenv.config({ path: 'random-file-name.jpg' })
and the code executed without any errors!
Currently, I'm using this hacky way to ensure that correct env file is loaded:
if (!dotenv.config({ path: '.env.local' }).parsed) { // throw an error or something... }
But I believe the path should do some checking to only allow .env.* files and throw an error if the file is invalid.
path
.env.*
👀 I think this PR is related: #651
We choose not to throw an error because in production the .env file won't be there.
.env
If you'd like to throw an error, you can do a file check first using node's fs lib. then pass to dotenv.
Config path accepts any string. I tried:
and the code executed without any errors!
Currently, I'm using this hacky way to ensure that correct env file is loaded:
But I believe the
path
should do some checking to only allow.env.*
files and throw an error if the file is invalid.👀 I think this PR is related: #651