-
Notifications
You must be signed in to change notification settings - Fork 24
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
Q: instructions regarding assignToProcessEnv unclear #55
Comments
Hi @leaumar . Thank you for the note. I just did a quick test and this seems to be working. Here is the simple example:
const dotenv = require('dotenv-extended');
dotenv.load({
assignToProcessEnv: true // default
});
console.log(`DB_HOST : ${process.env.DB_HOST}`);
console.log(`DB_USER : ${process.env.DB_USER}`);
console.log(`DB_PASS : ${process.env.DB_PASS}`);
console.log(`SHARE_URL : ${process.env.SHARE_URL}`); And here is the
The result of this shows the variable in Console output:
Which version of NodeJS are you using? Regarding the documentation. You are correct, this needs to be updated as the intention was that you won't be able to use them from your own javascript variable but you can use them from Can you please verify from the example above? |
I'll be able to test on tuesday (work project), but I can share that it's running on node12 via ts-node and yarn 3.0.2 (pnp enabled). |
I found the problem. Apparently we just got the pwd wrong (it's a multi-module project), we used Now my ticket becomes more of a feedback about dotenv-extended's behavior though. I have the following configured:
I've now learned that this code will not throw or log anything if the mentioned files cannot be found. You have to add Would it not make more sense for dotenv-extended to log a warning (or throw an error) when |
On a project I'm adding dotenv-extended to, we're using
assignToProcessEnv
for the first time (we kept values separated before). This doesn't seem to be working however, values are not assigned toprocess.env
. We'd like to rule out user error first, so we double-checked the readme and found this confusing line:What does this actually mean? All we can guess is we must
const values = dotenv.load(...);
(and then just ignorevalues
since the whole point is we wantprocess.env
) instead of justdotenv.load(...);
, but we don't see how "capturing" the return value this way can make any difference for the values being assigned toprocess.env
duringload()
. The const isn't fixing our problem anyway. Could you clarify, please? Thanks.The text was updated successfully, but these errors were encountered: