--env-file flag collision for node 20
keoz-simon opened this issue · comments
Hey! I'm trying to implement dotenvx to my TypeScript project.
This is my desired command:
dotenvx run --env-file=.env --env-file=.env.test --env-file=.env.test.local --overload ...
In case .env.test.local
or any other --env-file option is not present, dotenvx fails. I think native fs error bubbles up. I'd suggest and need for my case an option, that it doesn't fail if a file is not present. I think it's not mandatory to let it fail. What do you think?
thanks!
i think you're right. it shouldn't fail. it should just warn. will patch up.
what node version are you using here? maybe there is a flag collision i need to look into.
@motdotla v20.11.1
Which one are you using? I could recheck with yours.
OS is macOS 14.3
yes, that's the issue. node@18-latest works. node@20.11.1 doesn't.
we used --env-file because we like the principle of least surprise (keep in mind many devs use the binary rather than the npm install (in which case this is not an issue))
that said, to unblock you, use -f as the flag instead of --env-file. that should work.
i'll also reconsider the flag name.
If I didn't get you wrong: binary doesn't work too. But I'm totally with you using this flag name.
-f
would be a good workaround. Maybe + warning in README.
nevertheless best solution would be no collision at all.
thanks for your work
binary should work, but not the node_modules/.bin/dotenvx
since it's still dependent on the running node version.
the binary (or brew) installs can be done via:
brew install dotenvx/brew/dotenvx
or
curl -fsS https://dotenvx.sh/ | sh
there is some chatter with the Node team that they will replace the error with a warning - which I hope and expect to see.
So until then, I'm adding this issue to a new FAQ: