#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npm run lint
报错npm command not found in PATH: ...
因为GUI环境中启动husky,没有npm、nvm、node的PATH环境变量,需要跟配置bash、zsh等终端一样进行环境的配置
创建 ~/.huskyrc文章来源:https://www.toymoban.com/news/detail-764021.html
# ~/.huskyrc
export NVM_DIR="$HOME/.nvm"
# 如果终端是bash
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# 如果终端是zsh
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
或者export PATH=“$PATH:${node的路径}”文章来源地址https://www.toymoban.com/news/detail-764021.html
到了这里,关于VSCode/SourceTree等GUI界面操作Git时,使用nvm,husky pre-commit中npm等命令command not found的解决方案的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!