Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

envfile

bevry223.9kArtistic-2.07.1.0TypeScript support: included

Parse and stringify the environment configuration files and format, also known as .env files and dotenv files

.env, browser, config, configuration, deno, deno-edition, deno-entry, denoland, dotenv, env, envfile, es2022, module, node, typed, types, typescript

readme

envfile

Status of the GitHub Workflow: bevry NPM version NPM downloads
GitHub Sponsors donate button ThanksDev donate button Patreon donate button Liberapay donate button Buy Me A Coffee donate button Open Collective donate button crypto donate button PayPal donate button
Discord server badge Twitch community badge

Parse and stringify the environment configuration files and format, also known as .env files and dotenv files

What are environment configuration files?

They are files use to configure environments by applications and servers that support them. Generally they look like this:

a=1
b:2
c = 3
d : 4

They are commonly also called envfiles, .env files, and dotenv files.

Usage

Complete API Documentation.

Via the Command Line

Requires a global installation of envfile: npm install -g envfile

# envfile to JSON
echo -e "a=1\nb:2" | envfile env2json > config.json

# JSON to envfile
echo '{"a":1,"b":2}' | envfile json2env > config.env

Via Node.js

// Include envfile
const { parse, stringify } = require('envfile')

// Parse an envfile string
console.log(parse('a=1\nb:2'))

// Stringify a javascript object to an envfile string
console.log(stringify({ a: 1, b: 2 }))

Install

npm

Install Globally

  • Install: npm install --global envfile
  • Executable: envfile

Install Locally

  • Install: npm install --save envfile
  • Executable: npx envfile
  • Import: import * as pkg from ('envfile')
  • Require: const pkg = require('envfile')

Deno

import * as pkg from 'https://unpkg.com/envfile@^7.1.0/edition-deno/index.ts'

Skypack

<script type="module">
    import * as pkg from '//cdn.skypack.dev/envfile@^7.1.0'
</script>

unpkg

<script type="module">
    import * as pkg from '//unpkg.com/envfile@^7.1.0'
</script>

jspm

<script type="module">
    import * as pkg from '//dev.jspm.io/envfile@7.1.0'
</script>

Editions

This package is published with the following editions:

  • envfile/source/index.ts is TypeScript source code with Import for modules
  • envfile/edition-browsers/index.js is TypeScript compiled against ES2022 for web browsers with Import for modules
  • envfile aliases envfile/edition-es2022/index.js
  • envfile/edition-es2022/index.js is TypeScript compiled against ES2022 for Node.js 8 || 10 || 12 || 14 || 16 || 18 || 20 || 21 with Require for modules
  • envfile/edition-es2022-esm/index.js is TypeScript compiled against ES2022 for Node.js 12 || 14 || 16 || 18 || 20 || 21 with Import for modules
  • envfile/edition-types/index.d.ts is TypeScript compiled Types with Import for modules
  • envfile/edition-deno/index.ts is TypeScript source code made to be compatible with Deno

History

Discover the release history by heading on over to the HISTORY.md file.

Backers

Code

Discover how to contribute via the CONTRIBUTING.md file.

Authors

Maintainers

Contributors

Finances

GitHub Sponsors donate button ThanksDev donate button Patreon donate button Liberapay donate button Buy Me A Coffee donate button Open Collective donate button crypto donate button PayPal donate button

Sponsors

  • Andrew Nesbitt — Software engineer and researcher
  • Balsa — We're Balsa, and we're building tools for builders.
  • Codecov — Empower developers with tools to improve code quality and testing.
  • Poonacha Medappa
  • Rob Morris
  • Sentry — Real-time crash reporting for your web apps, mobile apps, and games.
  • Syntax — Syntax Podcast

Donors

License

Unless stated otherwise all works are:

and licensed under:

changelog

History

v7.1.0 2023 December 30

v7.0.0 2023 November 24

  • Updated dependencies, base files, and editions using boundation
  • Minimum required Node.js version changed from node: >=10 to node: >=8 adapting to ecosystem changes

v6.22.0 2023 November 23

v6.21.0 2023 November 21

v6.20.0 2023 November 15

v6.19.0 2023 November 13

v6.18.0 2022 September 8

v6.17.0 2021 July 30

v6.16.0 2021 July 30

  • Node v16 support
  • Now supports --env2json, --json2env as well.
  • Don't use npx in our tests anymore, it doesn't do what we want just causes problems, such as prompting for installs and messing with output.
  • Updated dependencies, base files, and editions using boundation

v6.15.0 2021 July 28

v6.14.0 2020 September 4

v6.13.0 2020 August 18

v6.12.0 2020 August 4

v6.11.0 2020 July 22

v6.10.0 2020 July 22

v6.9.0 2020 July 3

v6.8.0 2020 June 25

v6.7.0 2020 June 21

v6.6.0 2020 June 21

v6.5.0 2020 June 20

v6.4.0 2020 June 10

v6.3.0 2020 June 10

v6.2.0 2020 May 22

v6.1.0 2020 May 21

v6.0.0 2020 May 21

  • Breaking Changes:
    • API is now only stringify and parse
    • CLI is now envfile which takes the argument env2json or json2env and still receives input via stdin
  • Converted from JavaScript to TypeScript
  • Updated dependencies, base files, and editions using boundation

v5.2.0 2020 May 12

v5.1.0 2020 May 4

v5.0.0 2020 March 26

  • Updated dependencies, base files, and editions using boundation
  • Minimum required node version changed from node: >=8 to node: >=10 to keep up with mandatory ecosystem changes

v4.5.0 2019 December 9

v4.4.0 2019 December 1

v4.3.0 2019 December 1

v4.2.0 2019 December 1

v4.1.0 2019 November 18

v4.0.0 2019 November 18

  • Updated dependencies, base files, and editions using boundation
  • Minimum required node version changed from node: >=0.12 to node: >=8 to keep up with mandatory ecosystem changes

v3.1.0 2019 November 13

v3.0.0 2019 January 1

v2.3.0 2018 January 25

  • Updated base files and dependencies

v2.2.0 2018 January 25

v2.1.1 2016 May 27

  • Fixed missing dependency (regression since v1.2.0)

v2.1.0 2016 May 27

  • Updated internal conventions

v2.0.1 2016 January 14

v2.0.0 2016 January 14

  • Converted from CoffeeScript to ESNext
  • Updated internal conventions
  • Updated minimum supported node version from 0.6 to 0.12
  • Removed internally supported yet unused and undocumented opts argument
    • This may be a breaking change if you expected the completion callback to the 3rd argument instead of the 2nd argument
  • This release was live coded. You can watch it here.

v1.0.0 2013 May 8

  • Initial working release