![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
node-config-files
Advanced tools
While working on any Node project we often face the problem when we need to manage our configuration files based on environments. For instance, most well known environments are development
, test
and production
. And we not limited by them, right!? Projects can have non-standard
environment names and for each of them we want sleek and straight forward way of how we manage its configuration files. Here is why node-config-files
can come in handy.
By default node-config-file
looks for config
folder within the root of our project folder. And, it expects a file structure of this folder to be flat. In other words, node-config-files
doesn't support subfolders.
Default
<project_root>/config/*
NOTE: If you prefer to keep our configuration files in different folder, you should specify its path explicitly. See example
There are rules of how you name your configuration files in order to make them work with node-config-files
module.
A file name should follow the pattern: [section].[environment].config.js
Where:
Here examples of valid configuration file names:
project.config.js
database.development.config.js
rest_api.production.config.js
For files that do not belong to any environment its content will be available over property common
in global config object, and for files that do its content available over property env
.
To install the module run following command in your project folder.
npm i node-config-files --save
Create a folder where you are going to store configuration files for your applicaiton.
mkdir config
Once folder is created you can start add you configuration files to it.
NOTE: By default this module looks at config
folder in the root of your application. But this behaviour can be overridden.
For more detailed example please see tests
/*
Assume we have following config files
./config/project.config.js
./database/database.development.config.js
*/
const config = require('node-config-files')();
config.common.project; // project.config.js
config.env.database; // database.development.config.js
const config = require('node-config-files')(
'./server/config',
{
debug: true,
NODE_ENV: 'test'
}
);
NOTE: Make sure that your path is relative to your project root folder.
process.env.NODE_ENV
. (default: development)This is a common object which will be returned once node-config-files
module is invoked.
{
"common": {},
"env": {},
"packageConfig": {}
}
Contains the content of files which are environment independent.
Contains the content of files which are environment dependent.
Contains properties which were defined in package.json
file.
NOTE: Properties dependencies
and devDependencies
are not included.
Licensed under GNU GPLv3, see LICENSE for the full license.
FAQs
Simple node module to manage application configuration files
The npm package node-config-files receives a total of 4 weekly downloads. As such, node-config-files popularity was classified as not popular.
We found that node-config-files 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.