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
custom path doesn't work #116
Comments
sorry, kind of missed it in the doc.
instead of
|
Sorry for the confusion. Trying to make it clearer in #101 that |
@maxbeatty awesome! |
I'm sorry but I don't get it... I'm unsure where I should require, or set it to Thanks in advance. EDIT :Okay so I was sure I'd tried it but I came back to it fresh and it's much simpler than I expected :
And this can apparently be called multiple times and the values will be overwritten. EDIT 2 :Actually that doesn't work... |
You can call config many times but process.env will not be overwritten |
Arf, indeed, I don't know what I'd had done, I thought it worked but clearly it doesn't... Then I guess I still don't get it, I have the code I've written above, I do get what I've defined in my root .env file, but I'm not getting the variables I've written in the one I'm explicitly calling with .config()... What did I miss ? |
Here's how to debug and inspect what dotenv is doing: const dotenv = require("dotenv")
// enable debugging
const { parsed, error } = dotenv.config({ debug: true })
// was there an error?
console.error(error)
// what was parsed?
console.log(parsed)
// compare to process.env
console.dir(process.env) |
I've faced the same issue some weeks ago . . . // importing resolve from path module
const {resolve} = require('path')
require('dotenv').config({path: resolve(__dirname,"../../config/dev.env")}) i guess this isn't the prefect answer but it works ! |
@SiMoG97 worked for me! thanks!! |
Just a simple reminder of what have worked for me: You dont need to put the relative path inside const dotenv = require("dotenv");
dotenv.config({ path: "./config/.env" }); |
Thanks a lot. It works |
This helped me in finding the .env file 1 level up. |
Hi guys
I am trying to move my
.env.production
file intoconfig
dir.However, it doens't work.
config
dir the same level asapp.js
The text was updated successfully, but these errors were encountered: