Closed ilya-adnymics closed 1 year ago
Unfortunately, I can't reproduce the issue with the code you provided. Please provide a minimum reproduction repo with github or CodeSandbox.
The functionality to expand variables is covered in unit tests: https://github.com/Nikaple/nest-typed-config/blob/main/tests/e2e/dotenv.spec.ts#L147 https://github.com/Nikaple/nest-typed-config/blob/main/tests/src/.expand.env
And latest unit test result seems fine too: https://github.com/Nikaple/nest-typed-config/actions/runs/4423478314/jobs/7756255285#step:8:15
Note: Upgrading nest-typed-config
from v2.4.7 to v2.5.1 will bump the dependencies from dotenv@6
and dotenv-expand@5
to dotenv@16
and dotenv-expand@10
, maybe updating the dependencies in your project will help.
Thank you for looking into it! I did exactly the steps to reproduce here: https://stackblitz.com/edit/nestjs-typescript-starter-othd9g and get the same error.
I didn't have neither dotenv
nor dotenv-expand
dependencies before nest-typed-config, so they come together and are on the versions you mentioned.
If this might help, the error for me was that in transpiled JS code in v2.5.1 the dotenvExpand
had an expand
method on it, i.e. it seems like an import/require issue.
I think this might be it: Breaking Move default export to export of expand function, happened in v6 of dotenv-expand.
Also, the unit tests are passing because the actual version of dotenv-expand that gets installed is 5.1.0. I.e. somehow version from optionalDependencies
"beats" the one from devDependencies
, and the tests pass.
If you bump version in optionalDependencies, test will fail.
Thanks for your contribution! Closed by #278
I'm submitting a...
Current behavior
Seems that expanding env variables is not working anymore in v2.5.1. Setting the
expandVariables: true
in module config fordotenvLoader
gives errorReverting to v2.4.7 helped solving the issue.
Expected behavior
Expanding env variables works as described in documentation.
Minimal reproduction of the problem with instructions
This should be enough to reproduce. Create a .env file with following contents:
Create a simple config file:
In your
app.module.ts
file configure the NestTypedConfig:Start the project and the error will occur.
What is the motivation / use case for changing the behavior?
Environment