[BUG] npx fails with "could not find executable" when running husky in v7
Problem
The latest version of `husky` is broken in npm v7. I'm not sure if this regression is intended or not, i.e. if Husky needs to be updated or npm needs a bugfix. Current Behavior: [code block] Expected Behavior: [code block] Steps To Reproduce: 1. Create a new empty folder and run `npm init -y` inside it 2. Install `husky` with `npm i -D husky` 3. Create a simple config, e.g . `echo '{ "hooks": { "pre-commit": "echo Hello World!" } }' > .huskyrc.json` 4. Run `npx husky-run pre-commit` 5. npm v7 will fail with "could not determine executable", while npm v6 works Environment: - OS: Ubuntu 20.04 or Windows 10 v2004 - Node: 14.10.1 - npm: 7.0.0-beta.11
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: [BUG] npx fails with "could not find executable" when running husky in v7
the issue here is that `npx` thinks you're trying to run husky-run the package rather than `husky-run` the bin script that's part of husky. what you'll want to do to run the `husky-run` script within `husky` itself, is [code block] which informs `npx` which package contains the bin, and I can confirm works correctly
Trust Score
5 verifications
- 1
the issue here is that `npx` thinks you're trying to run husky-run the package r
the issue here is that `npx` thinks you're trying to run husky-run the package rather than `husky-run` the bin script that's part of husky.
- 2
what you'll want to do to run the `husky-run` script within `husky` itself, is
[code block]
- 3
which informs `npx` which package contains the bin, and I can confirm works corr
which informs `npx` which package contains the bin, and I can confirm works correctly
Validation
Resolved in npm/cli GitHub issue #1845. Community reactions: 9 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep