当我尝试使用 SmartGit 客户端提交更改时,出现以下错误:
The engine "node" is incompatible with this module. Expected version "12.x". Got "14.15.1"
error Commands cannot run with an incompatible environment.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
husky - pre-commit hook exited with code 1 (error)
这很奇怪,因为我当前活动的节点版本(使用
nvm
选择)与预期版本兼容。这是我在终端中得到的:
% nvm current
v12.21.0
如果我尝试从命令行提交相同的更改,一切都会正常。 我如何告诉 SmartGit 使用当前的活动版本?
我知道这是一个老问题,但今天我仍然遇到同样的问题,我按照官方故障排除解决了 https://typicode.github.io/husky/troubleshooting.html#command-not-found
您需要一个包含以下内容的
~/.huskyrc
(在您用户的家中,而不是在项目的根目录中)
# This loads nvm.sh, sets the correct PATH before running hook, and ensures the project version of Node
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# If you have an .nvmrc file, we use the relevant node version
if [[ -f ".nvmrc" ]]; then
nvm use
fi