git-husky

Cannot execute binary file: Exec format error (code 126)


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.


Solution

  • 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.