Personal Brand :: Social Media :: LinkedIn :: Post :: Loading .env files in bash scripts
⪼ Made with 💜 by Polyglot.
» Loading .env files in bash scripts «
Sometimes, it’s necessary to create a bash script that shares some of the same environment variables as it's associated Node.js application.
Below is how to handle loading the .env file when running a bash script assuming there is a .env file in the current working directory which includes a value for `API_KEY`.
Țechśavvy CEO
Best Practices for Safeguarding Secrets in Node.js Applications is an article I've recently written on my medium blog which goes in-depth on loading .env files in Node.js.
https://wilmoore.medium.com/best-practices-for-safeguarding-secrets-in-node-js-applications-b418aac49c9f
