Interview Prep/Git & GitHub/Submodules, LFS and Hooks

Commits work from the terminal, but from VS Code or a GUI client they fail with `husky - pre-commit script failed (code 127)` / `npx: command not found`.

IntermediateTroubleshootingSubmodules, LFS and Hooks
Answer

Likely causes → GUI apps don't load your shell profile, so tools installed via nvm, asdf, volta or Homebrew are not on the PATH the hook sees. Exit code 127 means "command not found".

Diagnose → Add echo $PATH > /tmp/hook-path.txt at the top of the hook and commit from the GUI.

Fix → For Husky v9, put PATH setup in ~/.config/husky/init.sh (sourced before each hook):

# ~/.config/husky/init.sh
export NVM_DIR="$HOME/.nvm"
. "$NVM_DIR/nvm.sh"

Or launch the editor from a terminal (code .) so it inherits your PATH.

Prevent → Keep hooks dependency-light and document the GUI PATH fix in the contributing guide.

All Git & GitHub questions Roadmap: Git & GitHub

More on Submodules, LFS and Hooks