Fixing "node: not found" Error with mise(jdx) and Husky

11/08/2024

I’ve been using mise as my Node.js version manager, and I encountered an error when trying to commit code using Git GUI apps like VS Code with Husky set up. The error looked like this:

/Users/user/project/node_modules/.bin/eslint: line 16: exec: node: not found
 ELIFECYCLE  Command failed.
husky - pre-commit script failed (code 1)

To fix this, I added the following line to my ~/.config/husky/init.sh:

export PATH="$HOME/.local/share/mise/shims:$PATH"

I found this solution in an issue on the Husky repository here.