
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
node-env-configs
Advanced tools
Loads configuration files based on the NODE_ENV.
npm i node-env-configs --save
Run the following commands at the root of your project
default config file.node-env-configs by default consumes this file and export the content as the default config when NODE_ENV is not set.
$ mkdir configs
$ vim configs/default.js # or vim config/default.json
// default.js
module.exports = {
protocol: 'http://',
host: 'localhost',
port: 8090,
}
production config file.node-env-configs will consume production.js and do a shallow merge over the default config.
$ vim configs/production.js
// production.js
module.exports = {
port: 8000
}
Now, create main.js and add the following code.
// ES5 way
const config = require('node-env-configs').default
console.log(config.port)
// ES6 way
import { port } from 'node-env-configs'
console.log(port)
By default, when you run main.js, node-env-configs will check for NODE_ENV and look for the filename matching the NODE_ENV. If NODE_ENV is undefined it will pick default.js | default.json from the root/configs/ and return it as the default config. So, here
$ node main.js
> 8090 #logs 'port' from the 'default.js'
If your set the NODE_ENV=production,
$ NODE_ENV=production node main.js
> 8000 #logs 'port' from the 'production.js'
ENV_CONFIGS_DIRDescription: This specifies node-env-configs where the config files are saved in the project.
Default: <projectRoot>/configs/
Usage:
$ ENV_CONFIGS_DIR=app/configs node main.js # now node-env-configs will look for configs from the specified path
SUPPRESS_ENV_CONFIGS_WARNINGSDescription: This specifies node-env-configs to do or do not show warnings and errors on the console.
Default: false
Usage:
$ SUPPRESS_ENV_CONFIGS_WARNINGS=true node main.js # this will suppress all the warnings and the errors
node-env-configs supports the following file formats
.js.jsonYou can have both the formats in the same project or the config directory.
The MIT License (MIT)
Copyright (c) 2016 Pranesh Ravi
Made with ♥ by Pranesh Ravi
FAQs
Loads configs based on your environment
We found that node-env-configs 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.