Finds and reads a project's commitizen configuration. This is the loader behind require('commitizen').configLoader.load(), published on its own so adapters can read their settings without depending on all of commitizen.
npm install @commitizen/configimport { load } from '@commitizen/config';
const config = load() || {};It also works with require():
const { load } = require('@commitizen/config');Returns the commitizen config object, or undefined when there is none.
- With
configPath: reads that file, relative tocwd, and nothing else. - Without it: starting in
cwd(default: the current directory) and walking up, uses the first directory that has.czrc,.cz.jsonorpackage.json, in that order. In apackage.jsonthe config isconfig.commitizen(or the deprecatedczConfig, with a warning). The search stops at that directory even when itspackage.jsonhas no commitizen config. - If that finds nothing: tries the same files in the home directory (
USERPROFILE,HOMEPATH, thenHOME).
.czrc and other files without a .json or .js extension may contain comments. A file with invalid JSON, or that isn't UTF-8, throws.
The file names load() looks for, in priority order: ['.czrc', '.cz.json', 'package.json'].
- Returns the same object as
require('commitizen').configLoader.load(). commitizen re-exports this package, so both always agree. - Node.js
^22.23.5 || ^24.22.3 || >=26.13.1. The package is an ES module with no top-level await, sorequire()works. - Unlike the copy inside earlier commitizen versions, it doesn't skip the home directory while tests run under Mocha. Tests that call
load()should pointHOME(andUSERPROFILEon Windows) at an empty directory.
MIT