Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore .env.example #825

Closed
FlawTECH opened this issue May 20, 2024 · 2 comments
Closed

Ignore .env.example #825

FlawTECH opened this issue May 20, 2024 · 2 comments

Comments

@FlawTECH
Copy link

FlawTECH commented May 20, 2024

Hi,
I have a project in which I supply a .env.example with the default values for easier deployment.
Anyone who wants to deploy this project then has to copy this file to a .env file and adjust configuration as needed.

I was expecting dotenv to automatically load the .env file by default, but it seems .env.example is prioritized if present over .env.
How do I prevent this from happening ?

I tried supplying { path: ['.env'] } but even that doesn't seem to work.

@motdotla
Copy link
Owner

@FlawTECH are you sure it does this? I've just double checked:

// index.js
require('dotenv').config()
console.log('Hello ' + process.env.HELLO)
# .env.example
HELLO="example"

output of node index.js

Hello undefined

P.S. you can use dotenvx genexample to auto-generate your .env.example files

@FlawTECH
Copy link
Author

Apologies, you are indeed correct.
I tried in a clean environment (something I should have done in the first place) and I don't reproduce the issue. Something must be poisoning my main project's environment.

Sorry for the trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants