# envr

> decide the environment the application is running in, loads config files

Latest version **2.1.4** (published 2018-07-16) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install envr
pnpm add envr
yarn add envr
bun add envr
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.1.4 |
| Published | 2018-07-16 |
| First published | 2015-05-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=v6 |
| Dependencies | 0 |
| Unpacked size | 11.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Michael van der Weg |
| Maintainers | ee |

## Links

- npm: https://www.npmjs.com/package/envr
- Repository: https://github.com/eventEmitter/envr
- Issues: https://github.com/eventEmitter/envr/issues
- npm.io page: https://npm.io/package/envr

## Recent versions

- 2.1.4 (latest) — 2018-07-16
- 2.1.3 — 2018-07-05
- 2.1.2 — 2018-01-18
- 2.1.1 — 2017-06-21
- 2.1.0 — 2017-06-21
- 2.0.1 — 2017-01-26
- 2.0.0 — 2017-01-26
- 1.0.0 — 2016-11-02
- 0.1.0 — 2015-05-12

## README

# envr

Checks for commandline parameters or environment variables to determine in which environment to run your application.


[![npm](https://img.shields.io/npm/dm/envr.svg?style=flat-square)](https://www.npmjs.com/package/envr)
[![Travis](https://img.shields.io/travis/eventEmitter/envr.svg?style=flat-square)](https://travis-ci.org/eventEmitter/envr)
[![node](https://img.shields.io/node/v/envr.svg?style=flat-square)](https://nodejs.org/)



## Configuring the Environment

Reads the `NODE_ENV` variable

    export NODE_ENV=production

values can be:

- prodcution
- live
- integration
- staging
- testing
- dev
- development

where production === live, integration === staging and dev === development

The `NODE_ENV` variable is overriden by setting any of those flags:

    --production (--live)
    --integration (--staging)
    --testing
    --dev (--development)






## API

Get the current environment


    const envr = require('envr');

    console.log(envr.env) // production, integration, testing or development


There are also methods to directl yquery the environment

    const envr = require('envr');

    envr.isProduction()
    envr.isIntegration()
    envr.isTesting()
    envr.isDevelopment()

All of thoe methods throw errors if the environment was not set



## Load environment aware js config files

Loads js config files from a directory using the pattern `${dirname}/config.${envr.env}.js`.
All toplevel properties of a config.js file that may reside in the same directory as the other
config files will overrife properties of the environment specific config file. The configfiles
msut export an obejct.


    const envr = require('envr');

    // async, __dirname is the dir containgin the configs
    cosnt config = envr.config(__dirname);

---
_Source: https://npm.io/package/envr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
