Can't commit using husky: .husky/pre-commit: line 4: npx: command not found
Asked Answered
K

1

5

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.

Kirit answered 9/8, 2022 at 19:16 Comment(0)
K
6

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

Kirit answered 9/8, 2022 at 19:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.