It seems like there was an issue running npx husky add .husky/commit-msg 'npx --no-install commitlint --edit $1' because the command part was more than one word. A workaround I found was to split it up into two parts.

1 - Call npx husky add .husky/commit-msg

This created an empty/ default file in the right place with the following content:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

undefined

2 - Then I just replaced undefined with npx --no-install commitlint --edit $1 and it works

This part of the commitlint docs helped me understand that doing it that way was okay

Hope this helps anyone else who encounters the same issue!

Answer from PMO1948 on Stack Overflow
🌐
npm
npmjs.com › package › commitlint
commitlint - npm
March 15, 2026 - Lint your commit messages. Latest version: 20.5.0, last published: a month ago. Start using commitlint in your project by running `npm i commitlint`. There are 121 other projects in the npm registry using commitlint.
      » npm install commitlint
    
Published   Mar 15, 2026
Version   20.5.0
🌐
Commitlint
commitlint.js.org
commitlint
By supporting npm-installed configurations it makes sharing of commit conventions easy. ... Get high commit message quality and short feedback cycles by linting commit messages right when they are authored. ... To get the most out of commitlint you'll want to automate it in your project lifecycle.
🌐
GitHub
github.com › conventional-changelog › commitlint
GitHub - conventional-changelog/commitlint: 📓 Lint commit messages
If your project does not contain ... add rules to your commitlint.config.js error message. This can be fixed by doing either of the following: Add a package.json file, declaring your project as an ES6 module. This can be done easily by running npm init es6....
Starred by 18.5K users
Forked by 965 users
Languages   TypeScript 92.2% | JavaScript 7.8%
🌐
Commitlint
commitlint.js.org › guides › getting-started.html
Getting started | commitlint
If your project does not contain ... add rules to your commitlint.config.js error message. This can be fixed by doing either of the following: Add a package.json file, declaring your project as an ES6 module. This can be done easily by running npm init es6....
🌐
Commitlint
commitlint.js.org › guides › local-setup.html
Guide: Local setup | commitlint
To use commitlint you need to setup commit-msg hook (currently pre-commit hook is not supported) To lint commits before they are created you can use Husky's commit-msg hook. You can find complete setup instructions on the official documentation. ... The following instructions are meant to husky@v9 if you are using a different version consult the official documentation of your version. ... npm install --save-dev husky # husky@v9 npx husky init # husky@v8 or lower npx husky install # Add commit message linting to commit-msg hook echo "npx --no -- commitlint --edit \$1" > .husky/commit-msg
🌐
Medium
medium.com › @abpeter14 › how-to-install-commitlint-husky-2024-f1157f14006f
How to Install Commitlint & Husky [2024] | by Peter Abraham | Medium
February 29, 2024 - First, we install the Commitlint CLI and the Conventional Commits configuration as development dependencies: npm install @commitlint/cli @commitlint/config-conventional --save-dev
🌐
npm
npmjs.com › @commitlint › prompt-cli
@commitlint/prompt-cli - npm
March 15, 2026 - commit prompt using commitlint.config.js. Latest version: 20.5.0, last published: 25 days ago. Start using @commitlint/prompt-cli in your project by running `npm i @commitlint/prompt-cli`. There are 23 other projects in the npm registry using @commitlint/prompt-cli.
      » npm install @commitlint/prompt-cli
    
Published   Mar 15, 2026
Version   20.5.0
Find elsewhere
🌐
npm
npmjs.com › package › commitlint-plugin-function-rules
commitlint-plugin-function-rules - npm
May 29, 2025 - Use the same rules that are available in commitlint. ... npm install --save-dev commitlint-plugin-function-rules @commitlint/cli @commitlint/config-conventional
      » npm install commitlint-plugin-function-rules
    
Published   Jan 06, 2026
Version   4.3.0
Author   Jeroen de Bruijn
🌐
freeCodeCamp
freecodecamp.org › news › how-to-use-commitlint-to-write-good-commit-messages
How to Write Good Commit Messages with Commitlint
November 12, 2021 - Firstly, we need to install the commitlint CLI and add a commitlint config (in this case the default Conventional Commits Config). npm install @commitlint/cli @commitlint/config-conventional --save-dev # OR yarn add -D @commitlint/cli @commitlint/config-conventional
🌐
Yarn
classic.yarnpkg.com › en › package › commitlint
commitlint
Fast, reliable, and secure dependency management
🌐
Commitlint
commitlint.js.org › guides › ci-setup.html
Guide: CI Setup | commitlint
name: CI on: [push, pull_request] permissions: contents: read jobs: commitlint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup node uses: actions/setup-node@v4 with: node-version: lts/* cache: npm - name: Install commitlint run: npm install -D @commitlint/cli @commitlint/config-conventional - name: Print versions run: | git --version node --version npm --version npx commitlint --version - name: Validate current commit (last commit) with commitlint if: github.event_name == 'push' run: npx commitlint --last --verbose - name: Validate PR commits with commitlint if: github.event_name == 'pull_request' run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
🌐
Medium
medium.com › @thecreativerio › an-easy-configure-husky-and-commitlint-in-your-project-48d25f2a3f63
How to configure Husky and Commitlint in your project | by Mostafa | Medium
January 27, 2024 - In this article, I try to explain a setup for Husky and Commitlint in a frontend React project. Still, it can be applied to any software development project that is using Git. You may have heard a lot about this tool before. Husky helps you to run custom scripts against your Git commits and pushes and It currently has 10 million downloads on NPM...
🌐
Medium
trishan9.medium.com › what-is-commitlint-why-to-use-how-to-setup-and-more-2832d50ccff3
What is Commitlint? Why to use? How to Setup and more | by Trishan Wagle | Medium
September 8, 2023 - How to setup Commitlint in your project: Step 1: Install Commitlint ``` # Install and configure if needed npm install — save-dev @commitlint/{cli,config-conventional} # For Windows: npm install — save-dev @commitlint/config-conventional @commitlint/cli # Configure commitlint to use conventional config echo “module.exports = { extends: [‘@commitlint/config-conventional’] };” > commitlint.config.js ```
🌐
DEV Community
dev.to › thecharacterv › git-better-with-commitlint-and-conventional-commits-21pp
Git Better with Commitlint and Conventional Commits - DEV Community
May 26, 2023 - Also make sure after running the command in step 2 to create the commitlint.config.js, the file must be UTF-8 in order to work (if in VSCode, check the bottom right corner. It may say UTF-16. This can be manually adjusted). Run the command npm install --save-dev @commitlint/config-conventional @commitlint/cli in your terminal .
🌐
Medium
blog.appsynth.net › commitlint-git-commit-standard-5ab8f77ef305
Commitlint — git commit standard!! | by Thanainan Khamthaen | Appsynth
February 22, 2023 - @commitlint/config-conventional is a shareable config from conventional (another-shared-configuration) npm install --save-dev @commitlint/cli @commitlint/config-conventional
🌐
npm
npmjs.com › package › commitlint-config-lerna-scopes
commitlint-config-lerna-scopes - npm
May 8, 2025 - Shareable commitlint config enforcing lerna package names as scopes. Latest version: 20.4.3, last published: 19 days ago. Start using commitlint-config-lerna-scopes in your project by running `npm i commitlint-config-lerna-scopes`. There are no other projects in the npm registry using ...
      » npm install commitlint-config-lerna-scopes
    
Published   Mar 03, 2026
Version   20.4.3
🌐
Conventional Commits
conventionalcommits.org › en › v1.0.0
Conventional Commits
types other than fix: and feat: are allowed, for example @commitlint/config-conventional (based on the Angular convention) recommends build:, chore:, ci:, docs:, style:, refactor:, perf:, test:, and others.
🌐
npm
npmjs.com › search
keywords:commitlint - npm search
npm · Sign UpSign In · Sort by: Default · Default · Most downloaded this week · Most downloaded this month · Most dependents · Recently published · Lint your commit messages · conventional-changelog · commitlint · library · core · escapedcat• 20.5.0 • 7 days ago • 2 dependents • MITpublished version 20.5.0, 7 days ago2 dependents licensed under $MIT ·
🌐
GitHub
github.com › dalisoft › commitlint-go-npm
GitHub - dalisoft/commitlint-go-npm: commitlint checks if your commit messages meets the conventional commit format · GitHub
commitlint checks if your commit messages meets the conventional commit format · npm integration for commitlint-go without any overhead so using full power of commitlint-go CLI performance and feature
Author   dalisoft