Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-dotenv

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-dotenv

Loads environment variables from .env file

  • 2.0.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20
increased by11.11%
Maintainers
1
Weekly downloads
 
Created
Source

dotenv

Written in typescript, full testing.

It can loads environment variables from a .env file into process.env or parse <key>=<value> string

Installation

npm i @jsdotenv/core

Usage

Add your application configuration to your .env file in the root of your project:

S3_BUCKET=YOURS3BUCKET
SECRET_KEY=YOURSECRETKEYGOESHERE

Then in your Nodejs app you can do something like

import dotenv from "@jsdotenv/core";

dotenv.load([__dirname + "/.env"]);
console.log(process.env["S3_BUCKET"]);

If you want to be really fancy with your env file you can do comments and exports (below is a valid env file)

# I am a comment and that is OK
SOME_VAR=someval
FOO=BAR # comments at line end are OK too
export BAR=BAZ

Or finally you can do YAML(ish) style

FOO: bar
BAR: baz

Multiple line is OK.

MULTI_DOUBLE_QUOTED="THIS
IS
A
MULTILINE
STRING"

Expand variables is OK.

OPTION_B=${OPTION_A}
OPTION_C=$OPTION_B
OPTION_D=${OPTION_A}${OPTION_B}
OPTION_E=${OPTION_NOT_DEFINED}

Command Mode

npm i create-dotenv -g

Usage

Execute commands using key-value pairs.

dotenv-cli -v KEY=VALUE -- bash -c 'echo "$BASIC"'

Execute commands using enviroment file.

dotenv-cli -e .env -- bash -c 'echo "$BASIC"'

Keywords

FAQs

Package last updated on 29 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc