https://github.com/anshuman-singh-93/simple-node-env
Load environment variable easily using file
https://github.com/anshuman-singh-93/simple-node-env
env environment environment-variables node-env node-env-config nodejs
Last synced: 8 months ago
JSON representation
Load environment variable easily using file
- Host: GitHub
- URL: https://github.com/anshuman-singh-93/simple-node-env
- Owner: anshuman-singh-93
- License: mit
- Created: 2019-04-26T09:06:16.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-26T09:26:47.000Z (almost 7 years ago)
- Last Synced: 2025-06-06T02:46:59.792Z (8 months ago)
- Topics: env, environment, environment-variables, node-env, node-env-config, nodejs
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simple-node-env
A tiny package that load the environment variables from file
## How to install
```npm install simple-node-env -S```
```yarn add simple-node-env```
## How to use
1. create a .env file in the current directory of the project.by default it read from the current directory. if you create in some other directory then pass the envpath in option
2. require the simple-node-env as soon as you code runs
``` require('simple-node-env')()```
## Extra configuration
``` require('simple-node-env')(options)```
### Options
#### envPath
Default: `path.resolve(process.cwd(), '.env')`
You may specify a custom path if your file containing environment variables is located elsewhere.
```js
require('simple-node-env')({ envPath: '/full/path/to/your/env/file' })
```
#### Encoding
Default: `utf8`
You may specify the encoding of your file containing environment variables.
```js
require('simple-node-env')({ encoding: 'latin1' })
```
#### Debug
Default: `false`
You may turn on logging to help debug why certain keys or values are not being set as you expect.
```js
require('simple-node-env')({ debug: process.env.DEBUG })
```
#### Overwrite
Default: `false`
In few scenerio you may want to overwrite the envirment variable if it is already exist
```js
require('simple-node-env')({ overwrite: true })