Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Access .env vars from package.json scripts #49

Open
mischlecht opened this issue Aug 16, 2018 · 2 comments
Open

Access .env vars from package.json scripts #49

mischlecht opened this issue Aug 16, 2018 · 2 comments

Comments

@mischlecht
Copy link

mischlecht commented Aug 16, 2018

Is there any way I can access my variables from the .env file in order to utilize them in my package.json scripts?

I'm attempting to store an API_KEY in the .env file and then pull it into a script in order to publish some bundles + source maps to Bugsnag.

If possible, I'd love to not have to hard code this API key in the script itself.

I've attempted the following script in my package.json file:

"get-api-key": "node -p \"require('react-native-dotenv')\""

and, when run, have received the following output:

> [email protected] get-api-key /Users/michaelschlecht/Documents/dev/mediShareMobile
> node -p "require('react-native-dotenv')"

[Function]
MS-MBP-CCM:mediShareMobile michaelschlecht$

Any ideas how I can access variables in my .env file?

@zetachang
Copy link
Owner

zetachang commented Aug 17, 2018 via email

@reemtariqq
Copy link

can I change it from package.json command?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants