-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Troubleshoot
- Before creating an issue, please check:
https://typicode.github.io/husky/troubleshoot.html
If you're migrating from husky 4, see:
https://typicode.github.io/husky/migrate-from-v4.html
Context
I'm inside a monorepo and have set up husky according to https://typicode.github.io/husky/how-to.html#project-not-in-git-root-directory.
My directory structure looks like this:
<root>
/wiki
/desktop
/docs
/.husky
/pre-commit
/package.json
/.lintstagedrc
I have these scripts in my package.json
:
"scripts": {
"prepare": "cd .. && husky ./docs/.husky",
"lint-staged": "lint-staged"
},`
My .lintstagedrc
looks like this:
{
"**/*.{ts,tsx,json,css,md}": "prettier --write"
}
My pre-commit
echo "running husky pre-commit hook 🐶"
cd docs # reference: https://typicode.github.io/husky/how-to.html#project-not-in-git-root-directory
npm run lint-staged
Committing files via the terminal works and logs the following:
~/repos/dsds2$ git commit -m "test"
running husky pre-commit hook 🐶
> [email protected] lint-staged
> lint-staged
✔ Backed up original state in git stash (00dd9480)
✔ Running tasks for staged files...
✔ Applying modifications from tasks...
✔ Cleaning up temporary files...
[docs/inf-arc a04e0925] test
1 file changed, 2 insertions(+)
When committing directory via VSCode, I get the following behavior:


Command output:
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
running husky pre-commit hook 🐶
docs/.husky/pre-commit: 3: npm: not found
husky - pre-commit script failed (code 127)
husky - command not found in PATH=...
Expected behavior: Committing via VSCode should behave the same as committing via terminal.
I honestly have no idea what might be causing this problem and how it could be addressed. I'd be grateful for any input.
I'm working on a Windows 11 machine inside the WSL