Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
dotenv-defaults
Advanced tools
Readme
A dotenv system that supports defaults.
Use the following to install this module:
npm i dotenv-defaults --save
This module supports all the features from the original dotenv module, so usage should be simple enough:
# .env.defaults, safe to commit
HOST=website.com
EMAIL=test@email.com
# .env, DO NOT COMMIT
HOST=mrsteele.dev
The result
require('dotenv-defaults').config()
// Or you can also load it directly like this
require('dotenv-defaults/config')
console.log(process.env.HOST)
// Outputs: mrsteele.dev
console.log(process.env.EMAIL)
// Outputs: test@email.com
Since this module does not provide TypeScript Type Definitions if you try to import it like import dotenv from "dotenv-defaults"
TypeScript will return an error.
Instead you should load it like this:
import "dotenv-defaults/config"
You can also call this module directly when using the node executable.
So, for example if you are running a custom script with node and you want to load your environment variables you can do the following node -r dotenv-defaults/config your-script.js
. (When using this method, please make sure that you have installed dotenv-defaults with npm or yarn in the same directory)
The only thing to note is that the original module supported an options
argument in the config
function.
This module supports that as well, but there is an added defaults
property that can allow you to define where that file is located. An example is shown below:
// all of these are the default values...
require(`dotenv-defaults`).config({
path: './.env',
encoding: 'utf8',
defaults: './.env.defaults' // This is new
})
MIT
FAQs
dotenv... but with defaults!
The npm package dotenv-defaults receives a total of 847,987 weekly downloads. As such, dotenv-defaults popularity was classified as popular.
We found that dotenv-defaults demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.