https://github.com/thalesfp/node-env-yml
Environment variable loader using yml files
https://github.com/thalesfp/node-env-yml
env environment-variables nodejs yaml yml
Last synced: about 1 month ago
JSON representation
Environment variable loader using yml files
- Host: GitHub
- URL: https://github.com/thalesfp/node-env-yml
- Owner: thalesfp
- Created: 2020-03-07T19:04:18.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-17T07:20:30.000Z (over 1 year ago)
- Last Synced: 2025-04-10T13:20:29.670Z (about 1 month ago)
- Topics: env, environment-variables, nodejs, yaml, yml
- Language: JavaScript
- Homepage:
- Size: 242 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node Env YML
[](https://github.com/thalesfp/node-env-yml/actions/workflows/node.js.yml)Environment variable loader using yml files.
## Installation
```bash
npm install env-yml
```## Usage
Declaring variables in a file (eg. .app.yml):
```yaml
# Variables available in any environment
DATABASE_HOST: '127.0.0.1'
DATABASE_PORT: '5432'# Variables available in development environment
development:
DATABASE_USER: 'user-dev'# Variables available in test environment
test:
DATABASE_USER: 'user-test'
```Reading the file:
```javascript
const loadEnv = require('env-yml');loadEnv();
console.log(process.env.DATABASE_HOST)
console.log(process.env.DATABASE_PORT)
console.log(process.env.DATABASE_USER)
```## Parameters
Optional configuration params:
| name | description | default value |
|---|---|---|
| path | path to yml file | .app.yml |
| encoding | encoding of yml file | utf8 |
| env | force environment section | development |Usage:
```javascript
const loadEnv = require('env-yml');loadEnv({
path: 'myapp.yml',
encoding: 'latin1',
env: 'staging',
});
```