Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stagas/read-dotenv
read a .env file into an object
https://github.com/stagas/read-dotenv
env environment environment-variables nodejs
Last synced: 14 days ago
JSON representation
read a .env file into an object
- Host: GitHub
- URL: https://github.com/stagas/read-dotenv
- Owner: stagas
- Created: 2021-10-31T16:13:50.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-31T16:18:11.000Z (about 3 years ago)
- Last Synced: 2024-09-03T07:39:43.080Z (2 months ago)
- Topics: env, environment, environment-variables, nodejs
- Language: TypeScript
- Homepage:
- Size: 81.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# read-dotenv
read a .env file into an object
## Installation
```sh
$ npm install read-dotenv --save
```## Usage
```js
import dotenv from 'read-dotenv'
```## Example
```sh
# .env
PORT=7777
HOST=my.host.com
``````js
// app.js
import dotenv from 'read-dotenv'const env = dotenv({
PORT: 3000,
HOST: 'localhost',
SOME: 'other option'
})// `env` is now:
{
PORT: 7777,
HOST: 'my.host.com',
SOME: 'other option',
}```
## API
### ▸ **dotenv**(`env?`, `root?`): _`Record`_
#### Parameters
| Name | Type | Description |
| :----- | :-------------------- | :----------------------------------------------------- |
| `env` | `Record` | The environment default object |
| `root` | `string` | The path where `.env` lives (default: `process.cwd()`) |## License
MIT