0

After I click Push in source tree, husky will run npm test and fail. I can find the message, 'husky > pre-push (node v17.9.0)'. So the node version is v17.9.0. I run unit test in my terminal which node version is v14.19.3 and succeed. How can I change the node version in my source tree or just change node version for husky? I use nvm to switch the node version, none of them is v17.9.0.

Anthony Wang
  • 93
  • 1
  • 1
  • 10

2 Answers2

1

Because I use nvm, and source tree doesn't import node version in nvm. So I input some code in ~/.huskyrc.

# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm

If you use zsh, just change some code

# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
Anthony Wang
  • 93
  • 1
  • 1
  • 10
-2

you need to use this

nvm use 14.19.3

note that you need to run this command as an administrator