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

dotenv-expand support? #97

Open
bhishp opened this issue Oct 31, 2019 · 5 comments · May be fixed by #253 or #342
Open

dotenv-expand support? #97

bhishp opened this issue Oct 31, 2019 · 5 comments · May be fixed by #253 or #342

Comments

@bhishp
Copy link

bhishp commented Oct 31, 2019

Is dotenv-expand supported? (https://github.com/motdotla/dotenv-expand)

I think not because I have attempted to add this to the env files but it doesn't work.REACT_APP_APP_VERSION=${npm_package_version}

(as per CRA docs:)
https://create-react-app.dev/docs/adding-custom-environment-variables/#expanding-environment-variables-in-env

Happy to raise a PR to add support if someone could point me in the right direction...

@toddbluhm
Copy link
Owner

toddbluhm commented Nov 1, 2019

Currently dotenv-expand is not supported and probably will never be supported. But the idea of expanding existing env vars is a really cool idea. I will look into implementing that. If you would like to throw together a PR to get this feature implemented sooner, feel free to do so 😄

@eckertalex
Copy link

@bhishp I had the same problem and I solved it by using dotenv-cli, which supports dotenv-expand.

You can use it as follows in you package.json:

"start": "dotenv -e .env.staging npm run develop",

@steveoh
Copy link

steveoh commented Jan 28, 2021

This is different from the existing --expand-envs correct? You have to send the vars in on the CLI or the env variable needs to already exist at run time iiuc?

It would be great to have REACT_APP_APP_VERSION=${npm_package_version} expand. If dotenv-cli can do it, we should be able to add the feature. Has the pr started for this?

Right now I am using an .env-cmdrc.json file with a .env file just for the version expansion. It's not ideal.

@nkrul
Copy link

nkrul commented Mar 10, 2021

I had a play - for simple expansions only, this should work:
#253

@nkrul nkrul linked a pull request Mar 10, 2021 that will close this issue
@motdotla
Copy link

motdotla commented Feb 12, 2024

you can use dotenvx for this

HELLO="World"
HELLO2=$HELLO
// index.js
console.log(`Hello ${process.env.HELLO}`)
console.log(`Hello ${process.env.HELLO2}`)
dotenvx run -- node index.js

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