commitlint: Not working with husky (cygpath)
husky > commit-msg (node v13.11.0)
/c/Users/yahyaaba/Documents/GitHub/atom-ide-community/atom-ide-datatip/node_modules/.bin/commitlint: line 5: cygpath: command not found
internal/modules/cjs/loader.js:979
throw err;
^
Error: Cannot find module 'C:\commitlint\cli.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15)
at Function.Module._load (internal/modules/cjs/loader.js:859:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
husky > commit-msg hook failed (add --no-verify to bypass)
My deps:
"@commitlint/config-conventional": "^8.3.4",
"commitlint": "^8.3.5",
"husky": "^4.2.5"
using "@commitlint/cli": "^8.3.5",
instead doesn’t help.
husky > commit-msg (node v13.11.0)
sh: commitlint: command not found
husky > commit-msg hook failed (add --no-verify to bypass)
Affected packages
- [ x] cli
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 7
- Comments: 15 (2 by maintainers)
try: cnpm install @commitlint/config-conventional @commitlint/cli -g
There is a solution in this issue: https://github.com/typicode/husky/issues/673#issuecomment-674292969 or this StackOverflow question: https://stackoverflow.com/questions/61196309/husky-4-x-not-working-with-visual-studio-git
We should use
npx
in the hooksVery strange. It was working perfectly until now, and suddenly it stopped working. Tried with GitExtensions (using external Git), VSC’s terminal, and regular terminal.
(Using an old Node because of project constraints.)
[EDIT] It might be related to pretty-quick which was upgraded to 3.0.0 from 2.0.1. It requires Node >= 10.13.0 but might fail with my 10.14 version… The error persisted after I changed back to 2.0.1 and doing a new install. I had to
rm -rf node_modules
and doingnpm i
again to get it to work again.Conclusion: it might be a bug with Husky, failing to chain to next task if one (silently) fails.
I identified the issue for my case - I was relying on SublimeMerge’s embedded Git. Once I configured it to use the system installed Git (i.e. Git for Windows), then the error went away.
@aminya You might wanna check if Atom is using an embedded Git as well, instead of your system’s Git.
Nope, it’s a problem of the used git distribution. cygpath seems also be missing in github desktop.
The included bash sets MSYS env, which causes the npm shell wrapper to use cygpath.
It is actually a Husky problem. I had the issue with GitHub Desktop, not Visual Studio. Husky v1 works fine for example.
It’s a visual studio issue, in the included git version the
cygpath.exe
is missing.https://developercommunity.visualstudio.com/t/Missing-cygpathexe-in-git/1393876