pre-commit hook failed (add --no-verify to bypass)

See original GitHub issue

I’m getting the following error:

Commit failed with error
			0 file committed, 2 files failed to commit: Add reformat with prettier and eslint precommit
			husky > pre-commit (node v13.9.0)
			C:\Users\...\frontend\node_modules\.bin/../node/bin/node: line 1: This: command not found
			husky > pre-commit hook failed (add --no-verify to bypass)

This is my package.json

  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.{js,jsx,ts,tsx}": [
      "prettier --write",
      "eslint --fix",
      "git add"
    ],
    "*.{html,css,less,ejs,json}": [
      "prettier --write",
      "git add"
    ]
  }

I tried everything that is mentioned here but nothing works.

I have the latest vesion of everything: intellij IDEA 2020.1, node 13.13.0, npm 6,14,4, git 2.24.0.windows.2, husky 4.2.5

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:11
  • Comments:20

github_iconTop GitHub Comments

36reactions
AnandB23commented, Oct 14, 2020

Finally found a solution. The issue (even though it’s not an issue! ) is because of the hooks created by react. I simply deleted the hooks folder for git which defines the pre-commit hooks and hence can push after that.

Edit: You can also skip hooks when you provide the git command line argument —no-verify, git push origin master --no-verify, or use Sourcetree‘s Bypass commit hooks setting (in the menu to the top right of the commit message field)

12reactions
Shinobi247commented, Sep 4, 2020

Hey @cjoecker, I believe this issue is because of the fact that git has its own pre-hooks, and now, with husky, you have added yours. I think there is a conflict between those two.

For a temporary solution, you can just delete the hook folder from ./git folder from your project or maybe move it out of your project folder(if you want). This worked for me. Hope so for you too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

husky > pre-commit hook failed (add --no-verify to bypass)
In my case I started getting husky > pre-commit hook failed (add --no-verify to bypass) once some dependencies have been updated.
Read more >
How to skip Git commit hooks | bobbyhadz
The --no-verify option can be used to bypass the pre-commit and commit-msg hooks. The pre-commit hook is run first and is used to...
Read more >
husky > pre-commit hook failed (add --no-verify to bypass)
git commit -m "message" --no-verify.
Read more >
Husky - Git hooks
Bypass hooks ​​ For Git commands that don't have a --no-verify option, you can use HUSKY environment variable: HUSKY=0 git push # yolo!...
Read more >
Fix Your Mistakes, Don't Commit Them! Pre-Commit Git Hook ...
It's time to stop committing broken tests, ugly code, type errors and lint errors to your git repository. With Husky, we can hook...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found