husky - pre-commit hook exited with code 127 (error) - npm command not found

76 views Asked by At

Why does husky not find npm? I tried husky in another project and it worked fine. The only difference to that other configuration is that i use npm and not pnpm now. Why does it fail?

prepare script in package.json: "prepare": "cd .. && husky install frontend/.husky"

pre-commit file:

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

cd ./frontend/

npm run format

the error I get runnning git commit --amend:

C:\Users\jfroe\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found
husky - pre-commit hook exited with code 127 (error)
husky - command not found in PATH=... /c/Users/jfroe/AppData/Roaming/npm ...

I tried adding npm to the path but it was included already: PATH=$PATH:$(dirname "$(which npm)").

0

There are 0 answers