git-commit-msg-linter
raw JSON → 5.0.8 verified Fri May 01 auth: no javascript
A lightweight, independent, zero-configuration git commit message linter that enforces the Angular Commit Message Guidelines. Version 5.0.8 requires Node >= 14.0.0. It operates as a git 'commit-msg' hook, instantly checking every commit message and aborting if invalid. Unlike commitlint or other tools, it requires no setup, configuration files, or additional dependencies. Ships with TypeScript type definitions. Release cadence: irregular, with occasional updates.
Common errors
error git-commit-msg-linter: commit message is invalid ↓
cause Commit message does not follow the Angular format: missing type or colon.
fix
Use format like 'feat: add login button' or 'fix(scope): resolve crash'.
error fatal: cannot run .git/hooks/commit-msg: No such file or directory ↓
cause The hook file is missing due to failed installation or .git directory not present.
fix
Reinstall npm package or manually remove and re-add the hook via npm rebuild.
error Error: EACCES: permission denied, open '.git/hooks/commit-msg' ↓
cause The npm install script lacks write permission to the .git/hooks directory.
fix
Run npm install with appropriate permissions (e.g., sudo on Unix).
error .commitlinterrc.json: no such file or directory ↓
cause Custom config file referenced but not found, or misspelled filename.
fix
Create 'commitlinterrc.json' in project root with correct spelling (no 'e' after 'lint').
error npm WARN deprecated git-commit-msg-linter@5.0.8: This package is no longer maintained ↓
cause The use of an outdated version that has been deprecated.
fix
Migrate to an alternative like @commitlint/cli or update to latest version if not deprecated.
Warnings
gotcha The hook is installed only if the .git directory exists. In CI environments without .git, installation may silently fail. ↓
fix Ensure .git is present before install, or use a conditional install script.
deprecated Node.js < 14.0.0 is no longer supported after version 5.0.0. ↓
fix Upgrade Node.js to >=14.0.0 or pin to version 4.x.
gotcha The hook uses 'commitlintrc.json' if present for customization, but the file name is easily misspelled as 'commitlintrc.json' (note the missing 'e' in 'linter'). ↓
fix Use correct filename: 'commitlinterrc.json' (no 'e' after 'lint').
gotcha When using with husky v5+, the hook may not trigger because husky manages its own hooks. The order of installation matters. ↓
fix Install husky after git-commit-msg-linter, or configure husky to run the linter script.
deprecated The package uses the 'gcm' hook; if you previously used another commit-msg hook, it may be overwritten. ↓
fix Backup existing hooks before installing.
gotcha In some environments (e.g., Windows with git bash), the hook may fail due to path issues. The error message is often unhelpful. ↓
fix Ensure Node.js is in PATH and the shebang line in the hook file is correct (usually '#!/usr/bin/env node').
breaking Version 5.0.0 changed the default enforcements: 'temp' type removed, 'style' now allows scope. ↓
fix Update commit messages to use valid types; adjust custom config if needed.
Install
npm install git-commit-msg-linter yarn add git-commit-msg-linter pnpm add git-commit-msg-linter Imports
- git-commit-msg-linter
import 'git-commit-msg-linter'
Quickstart
// In your project root, run:
npm install git-commit-msg-linter --save-dev
// Then commit:
git commit -m "feat: add new feature"
// To test linting, try:
git commit -m "bad commit"
// It will abort with a message listing valid types.