
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
process-env.json
Advanced tools
Tiny, Simple library to load config.json file into the process.env object.
npm i process-env.json
//config.json
{
"VALUE": "AWESOME"
}
//index.js
require('process-env.json')();
console.log(process.env.VALUE);
//custom-process-env.json
{
"VALUE": "AWESOME"
}
//index.js
//pass file name. relative paths work
require('process-env.json')('custom-process-env.json');
console.log(process.env.VALUE);
//pm2.json
{
"apps": [
{
"name": "app1",
"script": "index.js",
"cwd": "./app1",
"exec_mode": "cluster",
"watch": true,
"env": {
"PORT":"3333",
"MONGO_DB":"mongodb://127.0.0.1:27017/db"
}
},
{
"name": "app2",
"script": "index.js",
"cwd": "./app2",
"exec_mode": "cluster",
"watch": true,
"env": {
"PORT":"3444",
"MONGO_DB":"mongodb://127.0.0.1:27017/app"
}
}
]
}
//index.js
//pass file name
require('process-env.json')('pm2.json');
console.log(process.env.MONGO);
Note: for pm2 file with multiple apps. There is a secord argument you can supply on the require.
//index.js
//(filename, appIndex)
require('process-env.json')('pm2.json', 1);
console.log(process.env.MONGO);
Why would I need this if I have pm2 or nodemon? Well... if you have to a pm2 or nodemon server but also need to run cli scripts, this would be perfect for you. This library allows to you use your pm2 or nodemon file and load it into the process.env for cli scripts. Helpful, right?
//nodemon.json
{
"restartable": "r",
"ignore": [
"node_modules/"
],
"verbose": true,
"watch": [
"./"
],
"env":{
"MONGO":"mongodb://127.0.0.1:27017",
"PORT":"3401",
},
"ext": "js json"
}
//index.js
require('process-env.json')('nodemon.json');
console.log(process.env.MONGO);
For situations where you have mutliple envs and need to switch you env values, you can supply --config_file={env}.json and process-env.json will add that as the filename without you having to change your code.
//qa.json
{
"FOO": "BAR"
}
//staging.json
{
"FOO": "BAZ"
}
//index.js
require('process-env.json')('nodemon.json');
console.log(process.env.FOO);
node index.js --config_test=qa.json
//logs BAR
node index.js --config_test=staging.json
//logs BAZ
FAQs
Tiny library to load json file into process.env.
We found that process-env.json 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.