A tiny package that load the environment variables from file
npm install simple-node-env -S
yarn add simple-node-env
-
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
-
require the simple-node-env as soon as you code runs
require('simple-node-env')()
require('simple-node-env')(options)
Default: path.resolve(process.cwd(), '.env')
You may specify a custom path if your file containing environment variables is located elsewhere.
require('simple-node-env')({ envPath: '/full/path/to/your/env/file' })
Default: utf8
You may specify the encoding of your file containing environment variables.
require('simple-node-env')({ encoding: 'latin1' })
Default: false
You may turn on logging to help debug why certain keys or values are not being set as you expect.
require('simple-node-env')({ debug: process.env.DEBUG })
Default: false
In few scenerio you may want to overwrite the envirment variable if it is already exist
require('simple-node-env')({ overwrite: true })