{"id":10710,"library":"cz","title":"Simple Config Utility for Node.js","description":"Cz is a minimalistic configuration utility designed for Node.js applications, enabling developers to load, manage, and access configuration settings from files or programmatically. It provides methods for loading configuration files (e.g., JSON), setting default values, and getting/setting specific configuration properties using dot-notation paths. The package's current stable version is 1.8.2, released in early 2017. Due to a lack of updates since then, it is considered abandoned. Key differentiators include its extreme simplicity and reliance on CommonJS patterns, making it suitable for older Node.js projects but not for modern ESM-first environments. It provides basic configuration merging capabilities by applying changes on top of defined defaults, with options to reset the configuration or just its defaults.","status":"abandoned","version":"1.8.2","language":"javascript","source_language":"en","source_url":"https://github.com/OmgImAlexis/cz","tags":["javascript","config","utility","simple","configuration","tool"],"install":[{"cmd":"npm install cz","lang":"bash","label":"npm"},{"cmd":"yarn add cz","lang":"bash","label":"yarn"},{"cmd":"pnpm add cz","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used internally for utility functions within the configuration management.","package":"lodash","optional":false}],"imports":[{"note":"The `cz` package exports the `Cz` class directly. It is a CommonJS module, primarily intended for use with `require()` and instantiation with `new`.","wrong":"import Cz from 'cz';","symbol":"Cz","correct":"const Cz = require('cz');\nconst config = new Cz();"},{"note":"Configuration methods like `load` are available on an instantiated `Cz` object, not directly on the module export.","wrong":"const config = require('cz').load('./config.json');","symbol":"config.load()","correct":"const config = new Cz();\nconfig.load('./config.json');"},{"note":"Accessing configuration values requires an initialized `Cz` instance.","wrong":"require('cz').get('db:host');","symbol":"config.get()","correct":"const config = new Cz();\nconfig.get('db:host');"}],"quickstart":{"code":"const Cz = require('cz');\nconst config = new Cz();\n\n// Imagine 'config.json' exists with some data, e.g., { \"db\": { \"host\": \"localhost\" } }\n// For demonstration, we'll simulate the load with `set`\nconfig.set('db', {\n    host: 'localhost',\n    port: 27017,\n    username: 'user',\n    password: 'password',\n    collection: 'my-app'\n});\n\n// Sets Cz's default value for \"port\" to 4000\nconfig.defaults({\n    port: 4000\n});\n\n// Sets Cz to { random: 'random value' }\nconfig.set('random', 'random value');\n\n// This will return the whole config object currently loaded\nconsole.log('Current config:', config.get());\n\n// This will get { host: 'localhost', port: 27017, username: 'user', password: 'password', collection: 'my-app' } from the config object\nconsole.log('db config:', config.get('db'));\nconsole.log('db host:', config.get('db:host'));\n\n// Example of how to construct a connection string\nconst mongoUri = 'mongodb://' + config.get('db:username') + ':' + config.get('db:password') + '@' + config.get('db:host') + ':' + config.get('db:port') + '/' + config.get('db:collection');\nconsole.log('MongoDB URI (manual):', mongoUri);\n\n// Cz provides a helper to join gets for you\nconst mongoUriJoined = 'mongodb://' + config.joinGets(['db:username', 'db:password', 'db:host', 'db:port', 'db:collection'], [':', '@', ':', '/']);\nconsole.log('MongoDB URI (joined):', mongoUriJoined);","lang":"javascript","description":"This quickstart demonstrates how to instantiate `Cz`, set initial configuration, define default values, retrieve specific configuration properties using dot notation, and construct a practical connection string using both manual concatenation and `cz`'s `joinGets` helper."},"warnings":[{"fix":"Consider migrating to a actively maintained configuration library like `dotenv`, `config`, or `nconf` for ongoing support and compatibility.","message":"The `cz` package is effectively abandoned, with its last release (v1.8.2) in January 2017. It has not received updates for over seven years, which means it may not be compatible with newer Node.js versions or security best practices.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `require('cz')` for module imports. If you need ESM compatibility, you will need to use a different library or a CJS-to-ESM wrapper/bundler.","message":"Cz is a CommonJS-only module. It does not provide ESM (ECMAScript Module) exports, making it incompatible with `import` statements in modern Node.js or browser environments where ESM is preferred or required.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always instantiate `Cz` using `const config = new Cz();` before attempting to use its methods like `config.defaults()` or `config.set()`.","message":"The README documentation includes an example `const config = require('cz'); config.defaults({});` which incorrectly implies the `cz` module exports a direct instance or a function. The module actually exports the `Cz` class, requiring instantiation with `new Cz()` before methods can be called.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure `const Cz = require('cz');` is at the top of your file to import the class.","cause":"Attempting to use `Cz` as a global variable without explicit import or definition.","error":"ReferenceError: Cz is not defined"},{"fix":"Correct the import and instantiation: `const Cz = require('cz'); const config = new Cz(); config.defaults({});`","cause":"Calling a method like `defaults()` directly on the `require('cz')` result, instead of on an instantiated `Cz` object.","error":"TypeError: config.defaults is not a function"},{"fix":"Verify the `config.json` file path is correct and the file exists. Use an absolute path or ensure the relative path is correct based on where your script is run.","cause":"The file path provided to `config.load()` does not exist or is inaccessible from the current working directory.","error":"Error: ENOENT: no such file or directory, open './config.json'"}],"ecosystem":"npm"}