env-path
Loads environment variables from a chosen .env
file into process.env
, using dotenv and dotenv-expand
Adds
.env
variables toprocess.env
package.json"scripts":
Installation
$ npm install env-path
Usage
Thanks to dotenv-expand, we can use variables inside our .env
file.
See simple .env
file under
API_KEY=keyPORT=3000MONGO_DB=myDBMONGO_URL=mongodb://localhost:27017/${MONGO_DB}REACT_APP_VERSION=$npm_package_version
Run
Preloads dotenv and dotenv-expand. By doing this, you do not need to require and load dotenv and dotenv-expand in your application code.
Path
Specify a path using the -p
flag:
$ env-path -p path/.env-file node app.js
package.json"scripts":
Without path
Works similar to dotenv's Preload
See dotenv docs
$ env-path node app.js
package.json"scripts":