🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

env-path

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

env-path

Loads environment variables from a chosen .env file into process.env

1.0.7
latest
Source
npm
Version published
Weekly downloads
4.6K
14.84%
Maintainers
1
Weekly downloads
 
Created
Source

env-path

Loads environment variables from a chosen .env file into process.env, using dotenv and dotenv-expand

Adds .env variables to process.env

package.json
"scripts": {
  "test"  : "env-path -p path/.env node app.js"
  "build" : "env-path -p path/.env.production, react-scripts build"
  "start" : "env-path -p otherPath/.env-file react-script start",
}

Installation

NPM version

$ npm install env-path

Usage

Thanks to dotenv-expand, we can use variables inside our .env file.

See simple .env file under

API_KEY=key
PORT=3000
MONGO_DB=myDB
MONGO_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": {
  "build"   : "env-path -p path/.env.production, react-scripts build"
  "start"   : "env-path -p path/.env-file react-script start",
  "start2"  : "env-path -p path/.env.development node app.js",
  "start3"  : "env-path -p path/otherFileName.env node app.js",
}

Without path

Works similar to dotenv's Preload
See dotenv docs

$ env-path node app.js

package.json
"scripts": {
  "start"   : "env-path node app.js",
  "build"   : "env-path react-scripts build"
}

License

MIT

Keywords

env-path

FAQs

Package last updated on 29 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts