
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
corsenv
Corsenv is a zero-dependency module that loads environment variables from a .env file into process.env. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.
install locally (recommended) npm install cors-env --save Or installing with yarn? yarn add cors-env
Usage is easy!
Create a .env file in the root directory of your project. .env file
Add environment-specific variables on new lines in the form of NAME=VALUE
DB_HOST=localhost
DB_USER=root
DB_PASS=s1mpl3
As early as possible in your application, import and configure dotenv. // index.js require('cors-env').config()
console.log(process.env) // remove this after you've confirmed it working
.. or using ES6?
// index.mjs (ESM) import 'dotenv/config'; import express from 'express';
That's it! 🎉
process.env now has the keys and values you defined in your .env file.
require('cors-env').config()
...
const db = require('db') db.connect({ host: process.env.DB_HOST, username: process.env.DB_USER, password: process.env.DB_PASS })
FAQs
Set and Loads environment variables from .env file across platforms
We found that cors-env 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.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.