0

I'm using husky v8 and when I want to commit file changes on the repository I get this git error

.husky/pre-commit: line 4: npx: command not found
husky - pre-commit hook exited with code 127 (error)
husky - command not found in PATH=/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core:/usr/bin:/bin:/usr/sbin:/sbin

here is pre-commit file

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

npx lint-staged

this is prepare command in package.json

"prepare": "husky install",

I'm guessing I should define an environment variable

Yaya
  • 4,402
  • 4
  • 19
  • 43
  • 127 most is "command not found" which is also the first line of your error message: "npx: command not found" – knittl Jan 30 '23 at 12:33
  • So I guess the solution is to install `npx` on your system – knittl Jan 30 '23 at 12:46
  • @knittl Looks like `npx` is installed already. When I run `sudo npm i -g npx` it tells me the file already exists – Yaya Jan 30 '23 at 12:54
  • And when you type `npx` in your terminal? The error message is pretty clear about the fact that the binary is not found in `PATH=/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core:/usr/bin:/bin:/usr/sbin:/sbin` (the third line of the error) – knittl Jan 30 '23 at 12:55
  • I get the same error when trying to commit from within Visual Studio 2022. But I don't get an error when trying to commit from within Visual Studio Code, or command line git. As if Visual Studio 2022 uses different git installation or different path. – Thanasis Ioannidis Mar 25 '23 at 00:22

0 Answers0