husky: Command "husky-run" not found.
Just have upgraded from v4.3.8 to v5.0.9 and got the error
have tried to uninstall/install husky, remove npde_modules
- nothing helped
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
error Command "husky-run" not found.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 98
- Comments: 66 (3 by maintainers)
Commits related to this issue
- Yarn husky install https://github.com/typicode/husky/issues/854#issuecomment-776126582 — committed to trussworks/react-uswds by brandonlenz 3 years ago
- chore: run husky install issue 854 in husky repo: https://github.com/typicode/husky/issues/854 — committed to hasparus/theme-ui by hasparus 3 years ago
- Upgrade packages to latest possible versions Electron v12 introduced a breaking change, so we need to set contextIsolation to false for our app to continue to work. Also update husky to fix husky-run ... — committed to garyli2/Nightstand by garyli2 3 years ago
Try
yarn husky install
Try, npx husky install.
Alright, figured out how to fix it.
Firstly, we need to remove .git/hooks.
For me, I ran typicodes husky-4-to-5, which worked like a charm.
Then, run yarn / npx husky install.
Viola, should work. You can check out my repo to check out how I did it.
Some additional resources: From my testing, you can not add a .sh or any file extension to the end of a hook file. Add a hook using
yarn husky add '.husky/hook-name' 'optional content here'
(or npx) How you can run commitlint:Have a great day. 👋
Leave me a comment if this helped you out!
Initially, followed @Milo123459 and
deleted .git/hooks
and then was getting an error in following the next steps and git was committing code without hooks. Then triedyarn husky install
andyarn husky add .husky/pre-commit "lint-staged"
it worked. btw node is v15.8.0Replace lint-staged with yarn lint-staged
To fix
husky-run
not found, install husky 5 and runhusky init
script:With yarn:
With pnpm:
It will set up hooks and create a pre-commit hook that you can edit in
.husky/pre-commit
. If you want to add another hook, it’s highly recommended to usehusky add ...
command.Optionally, you can delete
.git/hooks
to remove artifacts from husky 4 (it’s automatically done if you upgrade withnpm
).There’s also section for migrating from husky 4 to 5 in the docs: https://typicode.github.io/husky/#/
Hope this helps 😃
do on Mac
it works!
package.json add
"prepare": "npx husky install",
Glad it worked!
Issue and fix: https://github.com/typicode/husky/issues/875
but my previous hooks are lost!!! 😦 my commitizen hooks are out of husky flow
No way, Husky 6?
I found this very helpful for mac osX - https://dev.to/studiospindle/using-husky-s-pre-commit-hook-with-a-gui-21ch Creating a huskyrc in the home directory and adding the path to your local/user npm files (
PATH="/usr/local/bin:/Users/julian/.npm/bin:$PATH"
) fixed the problems I had with husky not being able to find yarn despite having the npm/bin path in my global PATHNo. I’m on my phone, just replace $HUSKY_GIT_PARAMS with $1
it did not help me 😦 after reinstalling husky - it does not create /hooks folder in .git
@SalahAdDin try
yarn lint-staged
as seen in my example.We’re on the same page there, saying the same thing in different ways 👍
Package.json scripts are isolated which gives access to all binaries installed. The SH file is not. That’s why you have to prefix it.
I suggest just using yarn. That comment was purely for the fact he was using yarn, but you could do npx rather then yarn.
Should you use
yarn lint-staged
in your pre-commit as @Milo123459 suggests in the comment here?I’m doing the same and neither command errors on commit, but when run manually, only the command run as a
yarn
argument works.Thanks, @Milo123459 your suggestion works like a charm 🙌
Can confirm. This is so ridiculously annoying. Here is my solution