[Windows] [lint-staged] [GitHub Desktop] .husky/pre-commit script is unable to find `npx`
Author: trusktrCreated Aug 2, 2023Updated Apr 10, 2026
Troubleshoot
- Before creating an issue, please check: https://typicode.github.io/husky/troubleshooting.html
Context
Please describe your issue and provide some context:
- Terminal or GUI client (PowerShell, Git Bash, GitHub Desktop, ...) GitHub Desktop
- If applicable, content of the failing hook:
#!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" npx lint-staged - If possible, minimal steps to reproduce the issue
- There are no minimal steps for Windows (f.e. install Node.js, try a lot of things, hope it works, end with a workaround, then don't go back and figure it all out again).
Error:
/bin/bash: D:/Program Files (x86)/nodejs/npx: No such file or directory
husky - pre-commit hook exited with code 127 (error)
husky - command not found in PATH=...However I can git commit just fine in PowerShell or CMD, and it runs the hooks. I can see npx and other commands in my Path.
I get this issue when trying to commit in GitHub Desktop.
Workaround:
Using the direct path to the executable without npx solved the issue for now:
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
./node_modules/.bin/lint-stagedThank you!
Source: typicode/husky