Home > other >  Can't commit using husky: .husky/pre-commit: line 4: npx: command not found
Can't commit using husky: .husky/pre-commit: line 4: npx: command not found

Time:08-14

I have installed husky and it was working fine for months and then out of the blue today after a restart this error came up:

husky - command not found in PATH=/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core:/usr/bin:/bin:/usr/sbin:/sbin
.husky/pre-commit: line 4: npx: command not found

I don't know what could have caused it but I can't commit my changes. Obviously I could bypass the hook but I want to fix this issue.

CodePudding user response:

I went scouring the googs and found that running the following command works:

sudo launchctl config user path `echo $PATH`

This is the source of where I got it from: https://github.com/typicode/husky/issues/666#issuecomment-651919165

Which includes the context of where the solution came from: https://community.atlassian.com/t5/Bitbucket-questions/SourceTree-Hook-failing-because-paths-don-t-seem-to-be-set/qaq-p/274792

  • Related