yusenthebot

dotenv

Loads environment variables from .env file. Use when: reading and writing files with extras; directory operations; file pattern matching. NOT for: database replacement; network storage without proper SDKs.

yusenthebot 0 Updated 3mo ago
GitHub

Install

npx skillscat add yusenthebot/skills-pack/dotenv

Install via the SkillsCat registry.

SKILL.md

dotenv

Overview

Loads environment variables from .env file. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.

Installation

npm install dotenv

Core API / Usage

npm install dotenv --save
And as early as possible in your application, import and configure dotenv:

Common Patterns

Pattern 1

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

 

## Advanced

<details><summary>ES6</summary><br>

Import with [ES6](#how-do-i-use-dotenv-with-import):

Pattern 2

ES6 import if you need to set config options:

Pattern 3

</details>
<details><summary>bun</summary><br>

Configuration

And as early as possible in your application, import and configure dotenv:

Tips & Gotchas

  • Current version: 17.3.1. Check the changelog when upgrading across major versions.
  • Refer to the official npm page for edge cases and advanced configuration.