无法使用 husky 提交:.husky/pre-commit:第 4 行:npx:找不到命令

mis*_*ief 4 javascript npm husky git-husky npx

我已经安装了 husky,几个月来它工作正常,然后今天重新启动后突然出现此错误:

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
Run Code Online (Sandbox Code Playgroud)

我不知道是什么原因造成的,但我无法提交更改。显然我可以绕过这个钩子,但我想解决这个问题。

mis*_*ief 5

我去搜索了一下,发现运行以下命令是有效的:

sudo launchctl config user path `echo $PATH`
Run Code Online (Sandbox Code Playgroud)

这是我得到它的来源:https://github.com/typicode/husky/issues/666#issuecomment-651919165

其中包括解决方案来源的上下文:https://community.atlassian.com/t5/Bitbucket-questions/SourceTree-Hook-failing-because-paths-don-t-seem-to-be-set/qaq -p/274792