当我的Mac使用Git提交代码时,它会被Husky拒绝,我看到以下错误:
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
.husky/_/husky.sh: line 23: sh: command not found
husky - pre-commit hook exited with code 127 (error)终端或VSCode也报告错误。
我怎样才能克服这个错误?
发布于 2022-02-18 07:16:06
这是关于github.com/typicode/husky/husky.sh#L23
sh -e "$0" "$@"确保sh在您的$PATH中(通常是/bin/sh)
将一个echo "prg='$0'"添加到您的.husky/_/husky.sh中,只为了调试并检查它是否为'$0‘,没有找到它(为空)
并检查路径问题,第912期
我使用VS代码和Husky v6。
我从我的项目的根运行echo
$PATH。 然后,我将输出复制到pre-commit目录中的.husky文件。 我的预提交文件如下所示: #!/bin/sh .$(dirname "$0")/_/husky.sh“export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin”npx lint-staged“
正如OP所提到的,引用哈士奇/指挥部未找到,~/.huskyrc应该正确地设置NVM:
# ~/.huskyrc
# This loads nvm.sh and sets the correct PATH before running hook
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"https://stackoverflow.com/questions/71169228
复制相似问题