DEV Community

jeancatarina
jeancatarina

Posted on

fatal: cannot run .husky/pre-commit: No such file or directory

Error:

fatal: cannot run .husky No such file or directory

Best Solution

  • copy the content of the file (pre-commit) Image description
  • delete the file with error (pre-commit)
  • npx husky add ./.husky/pre-commit
  • open the file and paste the content
  • now will work

Another solutions

1- rm -rf node_modules && rm -rf yarn.lock && yarn install
2- chmod +x ./.husky/*
3- rm -rf .git/hooks/pre-commit

Latest comments (3)

Collapse
 
idleberg profile image
Jan T. Sott

The solution might not work, when the Editor is set to use CRLF. Using LF will fix this.

Collapse
 
carstingaxion profile image
Carsten Bach

Helped me too. Thanks for sharing.

Collapse
 
amitbeck profile image
Amit Beckenstein

Thanks!!!