Challenge - 5 Problems
Husky Hook Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the output of installing Husky with the correct command?
You run the command
npm install husky --save-dev in your project. What is the expected output message you should see to confirm Husky installed successfully?Attempts:
2 left
💡 Hint
Look for the message that confirms a package was added without errors.
✗ Incorrect
When you install Husky using npm, the output shows that a package was added and audited. Errors or missing commands indicate installation problems.
🔀 Workflow
intermediate1:30remaining
Which step correctly sets up Husky hooks to be shared with the team?
After installing Husky, which command should you run to initialize Husky hooks so they are tracked in your Git repository and shared with your team?
Attempts:
2 left
💡 Hint
This command creates the hooks folder and sets up Git hooks.
✗ Incorrect
Running
npx husky install creates the .husky folder and sets up Git hooks so they can be shared via the repository.❓ Configuration
advanced2:00remaining
Which package.json script ensures Husky hooks are installed automatically after cloning?
You want Husky hooks to be installed automatically when a team member clones the repo and runs
npm install. Which package.json script configuration achieves this?Attempts:
2 left
💡 Hint
This script runs automatically after dependencies are installed and before publishing.
✗ Incorrect
The
prepare script runs after npm install and is the recommended place to run husky install so hooks are set up automatically.❓ Troubleshoot
advanced2:00remaining
Why does the Husky hook not run after cloning the repo?
A team member cloned the repo and ran
npm install, but Husky hooks do not run on Git commits. What is the most likely cause?Attempts:
2 left
💡 Hint
Check if the hooks installation step runs automatically after install.
✗ Incorrect
Without the
prepare script running husky install, hooks are not set up after cloning and installing dependencies.✅ Best Practice
expert2:30remaining
What is the best way to share a new pre-commit hook with your team using Husky?
You want to add a new pre-commit hook that runs
npm test and share it with your team. Which sequence of commands and steps is best practice?Attempts:
2 left
💡 Hint
Think about how Git tracks files and how Husky hooks are stored.
✗ Incorrect
Husky hooks live in the .husky folder which must be committed and pushed. Adding the hook with
npx husky add creates the file. This ensures all team members get the hook after pulling.