
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
env-create
Advanced tools
Read in a .env.json file that contains valid JSON and assign top level properties to environment variables
Reads in a valid JSON file and creates environment variables for every top level object found in the resulting object, unless an environment variable of that name already exists. It will not overwrite existing environment variables. It will only create environment variables for the top level objects.
npm i env-create --save
Although at this point you should have made --save
your default
Let's assume you have a .env.json
at the root level of your project with the following contents
{
"secret1": {
"client_id": "123445",
},
"secret2": {
"access_token": "reallylongtoken",
},
}
Somewhere early in your code before you need the environment variables you add
require('env-create').load()
const firstSecret = JSON.parse(process.env.secret1);
const secondSecret = JSON.parse(process.env.secret2);
The load()
method will create a process environment variable for every top level object in the the default .env.json
file located at the root of your project. The load()
method optionally takes a JSON object with properties for path, debug,
and encoding
. All three properties are optional.
Using a relative path to go up one folder out of your project and into an ENV_VARS folder to get the file named gsweet.env.json
require('env-create').load({path: "../ENV_VARS/gsweet.env.json", encode: "utf8", debug: "true"});)
const firstSecret = JSON.parse(process.env.secret1);
const secondSecret = JSON.parse(process.env.secret2);
## Acknowledgement
Inspired by [dotenv](https://github.com/motdotla/dotenv)
FAQs
Read in a .env.json file that contains valid JSON and assign top level properties to environment variables
The npm package env-create receives a total of 8 weekly downloads. As such, env-create popularity was classified as not popular.
We found that env-create 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.