dotenv

  • Version 10.0.0
  • Published
  • 24.9 kB
  • No dependencies
  • BSD-2-Clause license

Install

npm i dotenv
yarn add dotenv
pnpm add dotenv

Overview

Loads environment variables from .env file

Index

Variables

variable load

const load: (options?: DotenvConfigOptions) => DotenvConfigOutput;
  • Deprecated

    since v7.0.0 Use config instead.

Functions

function config

config: (options?: DotenvConfigOptions) => DotenvConfigOutput;
  • Loads .env file contents into . Example: 'KEY=value' becomes { parsed: { KEY: 'value' } }

    Parameter options

    controls behavior

    Returns

    an object with a parsed key if successful or error key if an error occurred

function parse

parse: <T extends DotenvParseOutput = DotenvParseOutput>(
src: string | Buffer,
options?: DotenvParseOptions
) => T;
  • Parses a string or buffer in the .env file format into an object.

    Parameter src

    contents to be parsed

    Parameter options

    additional options

    Returns

    an object with keys and values based on src

Interfaces

interface DotenvConfigOptions

interface DotenvConfigOptions {}

    property debug

    debug?: boolean;
    • You may turn on logging to help debug why certain keys or values are not being set as you expect.

    property encoding

    encoding?: string;
    • You may specify the encoding of your file containing environment variables.

    property path

    path?: string;
    • You may specify a custom path if your file containing environment variables is located elsewhere.

    interface DotenvConfigOutput

    interface DotenvConfigOutput {}

      property error

      error?: Error;

        property parsed

        parsed?: DotenvParseOutput;

          interface DotenvParseOptions

          interface DotenvParseOptions {}

            property debug

            debug?: boolean;
            • You may turn on logging to help debug why certain keys or values are not being set as you expect.

            interface DotenvParseOutput

            interface DotenvParseOutput {}

              index signature

              [name: string]: string;

                Package Files (1)

                Dependencies (0)

                No dependencies.

                Dev Dependencies (8)

                Peer Dependencies (0)

                No peer dependencies.

                Badge

                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/dotenv.

                • Markdown
                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/dotenv)
                • HTML
                  <a href="https://www.jsdocs.io/package/dotenv"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>