Reputation: 51
Here are the error messages when I commit:
.husky/../npmw: line 30: .husky/../target/node/node: cannot execute binary file: Exec format error Using node installed locally .husky/../npmw: line 40: .husky/../target/node/node: cannot execute binary file: Exec format error Using npm installed locally .husky/../npmw: line 41: .husky/../target/node/node: cannot execute binary file: Exec format error husky - pre-commit hook exited with code 126 (error)
Not sure if it's related to .husky/precommit
content as below:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
"$(dirname "$0")/../npmw" exec --no-install lint-staged
Originally,I use git commit -m "xxx" --no-verify
, but now I'm not allowed to due to my supervisor.
I've tried npm install.
Upvotes: 3
Views: 4533
Reputation: 81
I have the same problem.
After hit
git commit -m "testing pre-commit code"
got error
.husky/pre-commit: .husky/pre-commit: cannot execute binary file husky
- pre-commit script failed (code 126)
Resolved that after change pre-commit file encoding from UTF-16 (as it is as default after initializing husky) to UTF-8. I have done this in VS Code.
It works! :))
Upvotes: 4
Reputation: 46
I guess this error appeared on Windows and husky version 5.x, and I also encountered the same problem, and then I deleted ./husky/commit-MSG files, and after manually re-creation, I can submit it normally.
Upvotes: 3