To fix this there are two methods, depending on which version of Husky you are already on.
If you’re using Husky v4 or lower, do the following:
rm -rf .git/hooks
npm install
For Husky v7 or greater, do the following:
# For NPM
npm install husky@7 --save-dev \
&& npx husky-init \
&& npm exec -- github:typicode/husky-4-to-7 --remove-v4-config
# For Yarn
yarn add husky@7 --dev \
&& npx husky-init \
&& npm exec -- github:typicode/husky-4-to-7 --remove-v4-config
# or
yarn add husky@7 --dev \
&& yarn dlx husky-init --yarn2 \
&& npm exec -- github:typicode/husky-4-to-7 --remove-v4-config
At this point you should be able to commit and have your hooks working again.
If anything goes wrong, please read the documentation for migration from 4 to 7.