简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM