How To Escape Node.js Config Chaos
Let’s take a look behind the scenes at a truth everyone ignores: Config files are awkward and difficult to manage.

Config files are overwhelming, and sometimes, they downright suck. You're probably familiar with the sight of a chaotic root directory filled with 10+ config files, which leaves your codebase looking like an abstract painting that only the brave could decipher.
Are all these config files necessary?
Or have some been left stale from packages no longer in use?
To add to the calamity, once Docker and Sentry get involved, you're left wrestling with more than five files each, all piling up into what can be best described as "Config Hell".
Diving deep into the chaos
The issue we’re facing is not exclusive to JavaScript, but rather to software development as a whole. As a real-life example, let’s consider a situation where you have your Dockerignore, editor config, local environment example, a slew of VS Lint stuff, Git ignore ….

Let's take a closer look at this situation, where the effort to synchronize the melody of all these packages working together may lead you down into the rabbit hole of config confusion.
Chaos theory maintains that the effects of disorder grow exponentially.
Unpacking the ‘Defaults Dilemma’
JavaScript tools, greatly unrestrained by personal bias, lack opinionated defaults, often leading developers into heavy configuration.
Imagine one's first encounter with Gmail's settings – overwhelmed by the configuration, they may abandon the mailbox altogether!

The demand for better default settings is, therefore, the first line of defense in preventing our descent into the abyss of configuration. And though some modern tools like Prettier do a commendable job, more still remains to be done.
// Prettier configuration example
module.exports = {
trailingComma: "es5",
tabWidth: 2,
semi: true,
singleQuote: true,
};Imagining the ideal config landscape
Following my extensive, and quite frankly, arduous journey to setting up ESLint configs, I've imagined what an ideal config landscape might look like.
For starters, an all-encompassing .config folder. This magical directory would hold all necessary config files, creating a seamless and organized hierarchy for your repo.
Within this wonderland, you could spread out subfolders for Docker, Node, Sentry, or whatever else catches your fancy. Not only would it provide a harmonious layout, but it would also spare developers from config fatigue.
Next, I envision that top-level libraries such as Prettier, Tailwind, and others would start supporting the check for a .config folder.
.
└── .config
├── docker
│ └── dockerfile
├── sentry
│ └── sentry.properties
└── node
└── package.jsonI also anticipate that the ultimate source of truth, the package.json, would serve as a universal config file for JavaScript.
// package.json
{
"name": "app",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {},
"dependencies": {},
"devDependencies": {}
}Sadly, projects mature enough to read package.json for specific config values are a rare breed, and tools outside the JavaScript ecosystem could never fathom working this way.
For more complex configurations, like Sentry, which encourage you to create a JavaScript file embedded in the shipped app, we need a stand-in defense layer –– and that, dear reader, is where our config folder returns to the rescue.
Deciding on a Solution
In conclusion, we need to settle down on a definitive resolution to support these structures in diverse projects. A combination of improved defaults, smart usage of packag.jsonwhere possible, and efficiently using a config folder should be our guiding principles.
Yes, Deno has made strides toward that goal by creating an environment with default settings and no configuration required.
It's time that we recognize configuration complications as a problem, and work diligently towards solving it.
The future of our codebase could very well depend on it.
Check this useful blog post published by Deno team :
In Plain English
Thank you for being a part of our community! Before you go:
- Be sure to clap and follow the writer! 👏
- You can find even more content at PlainEnglish.io 🚀
- Sign up for our free weekly newsletter. 🗞️
- Follow us on Twitter(X), LinkedIn, YouTube, and Discord.
