Skip to content

Commit 170c345

Browse files
committed
update README
1 parent 630fd75 commit 170c345

File tree

1 file changed

+42
-24
lines changed

1 file changed

+42
-24
lines changed

README.md

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
>
77
> [2 minute tutorial 📺](https://www.youtube.com/watch?v=YtkZR0NFd1g)
88
9+
* [usage](#usage)
10+
* [environments](#multiple-environments)
11+
* [deploying](#deploying)
12+
* [agents 🆕](#agents-as2)
13+
914
 
1015

1116
### Usage
@@ -28,51 +33,66 @@ And as early as possible in your application, import and configure dotenv:
2833

2934
```javascript
3035
require('dotenv').config() // or import 'dotenv/config' if you're using ES6
36+
...
3137
console.log(process.env) // remove this after you've confirmed it is working
3238
```
3339

3440
That's it. `process.env` now has the keys and values you defined in your `.env` file:
3541

36-
<details><summary>learn more</summary><br>
3742

38-
Install with any npm-compatible package manager.
43+
&nbsp;
3944

40-
```sh
41-
yarn add dotenv
42-
bun add dotenv
43-
pnpm add dotenv
44-
```
45+
## Advanced
4546

46-
For monorepos with a structure like `apps/backend/app.js`, put it the `.env` file in the root of the folder where your `app.js` process runs.
47+
<details><summary>ES6</summary><br>
4748

48-
```ini
49-
# app/backend/.env
50-
S3_BUCKET="YOURS3BUCKET"
51-
SECRET_KEY="YOURSECRETKEYGOESHERE"
49+
Import with [ES6](#how-do-i-use-dotenv-with-import):
50+
51+
```javascript
52+
import 'dotenv/config'
5253
```
5354

54-
And if you are [using ES6](#how-do-i-use-dotenv-with-import) import with config options:
55+
ES6 import if you need to set config options:
5556

5657
```javascript
5758
import dotenv from 'dotenv'
58-
dotenv.config({ path: 'app/backend/.env' })
59+
dotenv.config({ path: '/custom/path/to/.env' })
60+
```
5961

60-
...
62+
</details>
63+
<details><summary>bun</summary><br>
6164

62-
s3.getBucketCors({Bucket: process.env.S3_BUCKET}, function(err, data) {})
65+
```sh
66+
bun add dotenv
6367
```
6468

6569
</details>
70+
<details><summary>yarn</summary><br>
6671

67-
&nbsp;
72+
```sh
73+
yarn add dotenv
74+
```
75+
76+
</details>
77+
<details><summary>pnpm</summary><br>
6878

69-
* [Usage](#usage)
70-
* [Multiple Environments](#multiple-environments)
71-
* [Deploying](#deploying)
72-
* [Agents (AS2) 🆕](#agents-as2)
79+
```sh
80+
pnpm add dotenv
81+
```
7382

74-
## Advanced
83+
</details>
7584

85+
<details><summary>Monorepos</summary><br>
86+
87+
For monorepos with a structure like `apps/backend/app.js`, put it the `.env` file in the root of the folder where your `app.js` process runs.
88+
89+
```ini
90+
# app/backend/.env
91+
S3_BUCKET="YOURS3BUCKET"
92+
SECRET_KEY="YOURSECRETKEYGOESHERE"
93+
```
94+
95+
</details>
7696
<details><summary>Multiline Values</summary><br>
7797

7898
If you need multiline variables, for example private keys, those are now supported (`>= v15.0.0`) with line breaks:
@@ -105,8 +125,6 @@ SECRET_HASH="something-with-a-#-hash"
105125
Comments begin where a `#` exists, so if your value contains a `#` please wrap it in quotes. This is a breaking change from `>= v15.0.0` and on.
106126

107127
</details>
108-
109-
110128
<details><summary>Parsing</summary><br>
111129

112130
The engine which parses the contents of your file containing environment variables is available to use. It accepts a String or Buffer and will return an Object with the parsed keys and values.

0 commit comments

Comments
 (0)