New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsdotenv

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsdotenv

Gone are the days of flat .env files. This allows to you dynamically build your env.

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

dotenvjs

A runnable env environment

About

Gone are the days of using flat .env files. This module will help you to build your env should you need that flexability.

Example

Here is a simple example:

// .env.js

// Set your own defaults, whatever! Its your env anyways!
const env = {
  NODE_ENV: 'develop'
}

// Dynamically change thigns...
if (env.NODE_ENV === 'develop') {
  env.LOGGING = true
}

// Put all your vars into the exports!
module.exports = env

And you can now just use it as expected:

require('jsdotenv').config()

if (process.env.LOGGING) {
  console.log('Look Mom no hands!')
}

Installation

You can simply install:

npm i --save jsdotenv

And then create a .env.js file in your root. After that include this package like you see above and you are ready to go!

Additional Features

You can access this simple package with a simplified example, or use some of our additional Features.

parse

If you just wanna parse a file, try the following:

const jsdotenv = require('jsdotenv')

const parsed = jsdotenv.parse('/path/to/some/file.js')
console.log(parsed) // will be the evaluated parsed result.
config

The example above is the minimalistic approach of the config function. You can also use advanced features as well like so (defaults in parenthesis):

require('jsdotenv').config({
  path: '.env.js' // The .env file to evaluate.
})

License

MIT

Keywords

FAQs

Package last updated on 21 May 2018

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