# @pixeloven-core/env

> Environment loader

Latest version **6.4.0** (published 2021-01-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @pixeloven-core/env
pnpm add @pixeloven-core/env
yarn add @pixeloven-core/env
bun add @pixeloven-core/env
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.4.0 |
| Published | 2021-01-29 |
| First published | 2019-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 159.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Brian Gebel |
| Maintainers | briangeb |

## Links

- npm: https://www.npmjs.com/package/@pixeloven-core/env
- Repository: https://github.com/pixeloven/pixeloven
- Homepage: https://www.pixeloven.com
- Issues: https://github.com/pixeloven/pixeloven/issues
- npm.io page: https://npm.io/package/@pixeloven-core/env

## Dependencies (2)

- [dotenv](https://npm.io/package/dotenv.md) 8.0.0
- [@pixeloven-core/exceptions](https://npm.io/package/@pixeloven-core/exceptions.md) ^6.4.0

## Recent versions

- 6.4.0 (latest) — 2021-01-29
- 6.3.1 — 2020-11-18
- 6.3.0 — 2020-11-13
- 6.2.0 — 2020-10-21
- 6.1.0 — 2020-10-08
- 6.0.1 — 2020-06-02
- 6.0.0 — 2020-06-02
- 6.0.0-rc.28 — 2020-06-02
- 6.0.0-rc.26 — 2020-05-28
- 6.0.0-rc.24 — 2020-05-22
- 6.0.0-rc.12 — 2020-04-07
- 6.0.0-rc.5 — 2020-02-11
- 6.0.0-rc.1 — 2020-02-06
- 6.0.0-rc.0 — 2020-02-05
- 6.0.0-beta.33 — 2020-02-04
- … 12 more at https://npm.io/package/@pixeloven-core/env/versions

## README

# @pixeloven-core/env

> Pixel Oven env.

See our website [PixelOven](https://www.pixeloven.com/) for more information or our [issues](https://github.com/pixeloven/pixeloven/issues) board to report issues associated with this package.

## Install

Using npm:

```sh
npm install --save @pixeloven-core/env
```

or using yarn:

```sh
yarn add @pixeloven-core/env
```

## Usage

> Note this package should only be used for node based applications. Using in a client setting may have unintended consequences.

This package acts as a simple wrapper for [dotenv](https://www.npmjs.com/package/dotenv) and a light weight interface for accessing our `.env` file variables. The philosophy for this project enforces only a single **environment** file aptly named `.env`. It is our opinion that having multiple `.env` definitions is an anti-pattern and should be discouraged.

The ideal setup for this particular configuration is to have a single `.env` file that's not committed to source control and instead should be manged the deployment process (or local development environment). Of course the deployment process may simply be pre-defined `.env-{template}` files in source that get _deployed_ based on environment but these details we leave to you. :heart:

Alright, enough lecturing let's get to coding! ;)

To use this package is simple. For example let use the following `.env` file as an example.

```
PORT=8080
HOST=localhost
PROTOCOL=http
PUBLIC_URL=/
BUILD_PATH=dist
LOG_LEVEL=debug
MACHINE=host
DOMAIN=pixeloven.com
```

The above ENV variables are some examples of common configurations used in our projects some of which are even defined in this package. Of course more variables can be added by simply following the below pattern.

```
VARIABLE_NAME=value
```

Now, in some cases it is required to defined environment variables at run time. For example if we wanted to bootstrap our build script to create a production build of our application.

```javascript
import { env, Environment } from "@pixeloven/env";

/**
 * Initialize env variables from file
 */
env.load();

/**
 * Setup production environment
 */
const environment: Environment = "production";
env.define("BABEL_ENV", environment);
env.define("NODE_ENV", environment);
```

Once again this packages pre-defines a few common variables and even provides type definitions but we are not limited to just what is defined by this package.

Enjoy!

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