# multi-env-config

> Multi environment configuration

Latest version **0.1.6** (published 2018-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install multi-env-config
pnpm add multi-env-config
yarn add multi-env-config
bun add multi-env-config
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.6 |
| Published | 2018-02-17 |
| First published | 2018-02-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Pedro Neves |
| Maintainers | pedro.f.neves |
| Keywords | config, environment |

## Links

- npm: https://www.npmjs.com/package/multi-env-config
- Repository: https://github.com/pedrofneves/multi-env-config
- Homepage: https://github.com/pedrofneves/multi-env-config#readme
- Issues: https://github.com/pedrofneves/multi-env-config/issues
- npm.io page: https://npm.io/package/multi-env-config

## Dependencies (1)

- [path](https://npm.io/package/path.md) ^0.12.7

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.1.6 (latest) — 2018-02-17
- 0.1.5 — 2018-02-17
- 0.1.4 — 2018-02-16
- 0.1.3 — 2018-02-16
- 0.1.2 — 2018-02-15
- 0.1.1 — 2018-02-15
- 0.1.0 — 2018-02-15

## README

## Multi env config

Multiple environment configuration file. 

## Install

~~~ Coffee-script
npm install multi-env-config --save
~~~

## Init

First you need to initialize the module using the following code in your main/start javascript file (for exemple, "index.js"):

~~~ Coffee-script
const config = require('multi-env-config').init();
~~~

The module expects configuration files in "./src/Config" directory relative to the project's base path.

The configuration file name must be the value assigned to "NODE_ENV" environment variable plus ".js".

Alternatively, you can initialize the module specifying your environment variable - in case you have many node instances in the same machine - and the directory of the configuration files.

For example, in the following initialization...

~~~ Coffee-script
const config = require('multi-env-config').init('MY_PROJECT_NODE_ENV', './src/configuration');
~~~

... if your MY_PROJECT_NODE_ENV environment variable has the value "development" the module will look for a "development.js" file in the "./src/configuration" directory.


## Usage

When you need to access some property of you configuration file just use:

~~~ Coffee-script
const config = require('multi-env-config');
~~~

For example, if your "development.js" file has the following data:

~~~ Coffee-script
module.exports = {
	database: {
		server: '192.168.0.10',
		user: 'root',
		password: '123456'
	}
}
~~~

you can access the data as following:

~~~ Coffee-script
const config = require('multi-env-config');
let server = config.database.server;
let user = config.database.user;
~~~

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