dotenv-auto
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

Deprecation

Warning: This extension library is deprecated. It is now recommended to install dotenv and use import 'dotenv/config' directly to load environment variables.

dotenv-auto

This lib automatically loads .env files according to to the standard .env file resolution and then replaces all references in your code to process.env.[VARNAME].

Install

npm install dotenv-auto
# OR
yarn add dotenv-auto
# OR
pnpm add dotenv-auto

Usage

Simply import at the top of the file.

import 'dotenv-auto';

API

config()

Sometimes it is necessary to manually reload, so you can use:

import { config } from 'dotenv-auto/api';

config();

console.log(process.env.APP_NAME);

env()

To retrieve a single key value, just use env:

import { env } from 'dotenv-auto/api';

const appName = env('APP_NAME');

console.log(process.env.APP_NAME);

/dotenv-auto/

    Package Sidebar

    Install

    npm i dotenv-auto

    Weekly Downloads

    42

    Version

    2.0.3

    License

    MIT

    Unpacked Size

    3.98 kB

    Total Files

    6

    Last publish

    Collaborators

    • caioedut