Socket
Socket
Sign inDemoInstall

dot-env-json

Package Overview
Dependencies
1
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dot-env-json

package similar to dotenv that reads from JSON file.


Version published
Weekly downloads
8
increased by300%
Maintainers
1
Install size
17.5 kB
Created
Weekly downloads
 

Readme

Source

dotenv-json

Package similar to dotenv to read from .json files. It looks for files based on NODE_ENV. Ex: .env.development.json

Usage

ES6

import dotenv from "dot-env-json";
dotenv();

CMD

node -r dot-env-json/lib/config
# change base directory from root
node -r dot-env-json/lib/config dotenv_config_base=config/

Configuration

Accepts an options object. Only valid option currently is base which sets the base path to look for files.

import dotenv from "dot-env-json";

# approot/config/.env.development.json
dotenv({
  base: "config/"
});

Cross Env

Since this package uses NODE_ENV it is recommended to use the cross-env package to set the environment in your run scripts

# gets the json file approot/env.test.json
cross-env NODE_ENV=test node -r dot-env-json/lib/config yourfile.js
# gets the json file approot/config/env.development.json
cross-env NODE_ENV=development node -r dot-env-json/lib/config dotenv_config_base=config/ yourfile.js

Keywords

FAQs

Last updated on 27 Sep 2017

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc