Skip to content

Commit ea1d669

Browse files
committed
update README
1 parent 24f848e commit ea1d669

1 file changed

Lines changed: 22 additions & 45 deletions

File tree

README.md

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,6 @@ Install it.
1414
npm install dotenv --save
1515
```
1616

17-
<details><summary>learn more</summary><br>
18-
19-
You can use any npm-compatible package manager like yarn, bun, or pnpm.
20-
21-
```sh
22-
yarn add dotenv
23-
bun add dotenv
24-
pnpm add dotenv
25-
```
26-
27-
&nbsp;
28-
29-
</details>
30-
31-
&nbsp;
32-
3317
Create a `.env` file in the root of your project:
3418

3519
```ini
@@ -38,55 +22,48 @@ S3_BUCKET="YOURS3BUCKET"
3822
SECRET_KEY="YOURSECRETKEYGOESHERE"
3923
```
4024

41-
<details><summary>learn more</summary><br>
42-
43-
For monorepos with a structure like `apps/backend/app.js`, put it in the root of the folder where your `app.js` process runs.
44-
45-
```ini
46-
# app/backend/.env
47-
S3_BUCKET="YOURS3BUCKET"
48-
SECRET_KEY="YOURSECRETKEYGOESHERE"
49-
```
50-
51-
&nbsp;
52-
53-
</details>
54-
5525
And as early as possible in your application, import and configure dotenv:
5626

5727
```javascript
58-
require('dotenv').config()
28+
require('dotenv').config() // or import 'dotenv/config' if you're using ES6
5929
console.log(process.env) // remove this after you've confirmed it is working
6030
```
6131

62-
<details><summary>learn more</summary><br>
63-
64-
If you are [using ES6](#how-do-i-use-dotenv-with-import):
32+
That's it. `process.env` now has the keys and values you defined in your `.env` file:
6533

6634
```javascript
67-
import 'dotenv/config'
35+
require('dotenv').config()
36+
...
37+
s3.getBucketCors({Bucket: process.env.S3_BUCKET}, function(err, data) {})
6838
```
6939

70-
or using ES6 import with config options:
40+
<details><summary>more details (expand)</summary><br>
7141

72-
```javascript
73-
import dotenv from 'dotenv'
42+
Install with any npm-compatible package manager.
7443

75-
dotenv.config({ path: '/custom/path/to/.env' })
44+
```sh
45+
yarn add dotenv
46+
bun add dotenv
47+
pnpm add dotenv
7648
```
7749

78-
</details>
50+
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.
7951

80-
&nbsp;
52+
```ini
53+
# app/backend/.env
54+
S3_BUCKET="YOURS3BUCKET"
55+
SECRET_KEY="YOURSECRETKEYGOESHERE"
56+
```
8157

82-
That's it. `process.env` now has the keys and values you defined in your `.env` file:
58+
And if you are [using ES6](#how-do-i-use-dotenv-with-import) import with config options:
8359

8460
```javascript
85-
require('dotenv').config() // or import 'dotenv/config' if you're using ES6
86-
...
87-
s3.getBucketCors({Bucket: process.env.S3_BUCKET}, function(err, data) {})
61+
import dotenv from 'dotenv'
62+
dotenv.config({ path: '/custom/path/to/.env' })
8863
```
8964

65+
</details>
66+
9067
&nbsp;
9168

9269
* [Usage](#usage)

0 commit comments

Comments
 (0)