How to fix command not found error using husky with asdf


I was working on a project that uses husky to run some scripts before commit, and I was using asdf to manage my node versions. I was getting this error when I tried to commit:

 /bin/sh: yarn: command not found

I found a solution that worked for me. I added my $PATH content path to the ~/.huskyrc file.

You can get the $PATH content, I just ran echo $PATH in your terminal.

So, it will be something like this:

## ~/.huskyrc
export PATH=">>$PATH CONTENT HERE<<"

And it worked. I hope it helps you too.