Comments (11)
npm uninstall removes the node modules, but doesn't uninstall the git hooks in you '.git/hooks' folder, so that hook keeps referencing the already removed node module. It would be nice of this module had a 'reset-hooks' method or something.
from pre-commit.
Solution - remove all previous hooks
rm .git/hooks/pre-commit
from pre-commit.
go to .git folder and remove hook folder and then solve your issue
from pre-commit.
How did you remove the dependency?
from pre-commit.
I ran npm uninstall pre-commit --save-dev
from pre-commit.
In that case, i'm guessing that our uninstall script needs to updated for proper un-installation. Thanks for the heads up.
from pre-commit.
Had the same issue. In my case probably yarn install
somehow skipped uninstall script 😕
To cancel old hook I manually replaced .git/hooks/pre-commit with .git/hooks/pre-commit.old
from pre-commit.
+1
from pre-commit.
For whatever reason mine got messed up as well. You can rm .git/hooks/pre-commit
, but I just did
yarn add pre-commit
yarn remove pre-commit
and that got it back to working condition (and restored my old hooks, which the previous solution does not do).
from pre-commit.
I ran into trouble here when we decided to change from pre-commit to pre-push.
I might be wrong, but I think the issue might be that the uninstall removes the pre-commit hook on the machine of the person doing the uninstalling, but not other people who may already have the code checkout out with the hook in place, but now referencing a module which no longer exists.
It's mildly annoying to have to leave pre-commit installed to avoid this problem, but the original poster's suggestion seems to be the least workflow disrupting solution for now.
from pre-commit.
This could be added to the readme:
#!/usr/bin/env sh
[[ -f .git/hooks/pre-commit ]] && {
echo 'De-activating old git hook (.git/hooks/pre-commit), by renaming to `.git/hooks/pre-husky-pre-commit-hook`'
echo 'The old hook does not work, because `node_modules/pre-commit` has been replaced with husky'
echo 'If you want to run eslint pre-commit, simply `yarn run activate-git-hooks`'
echo 'Feel free to add other scripts to .husky/pre-commit under an opt-in flag.'
echo 'You can also keep husky deactivated, and simply put anything you want in your `.git/hooks/pre-commit` file'
echo 'Activating/deactivating husky does not modify .git/hooks directory.'
echo 'It modifies .git/config core.hooksPath to point to .husky/ directory instead of using .git/hooks directory.'
mv .git/hooks/pre-commit .git/hooks/pre-husky-pre-commit-hook
}
You can run this in a postinstall hook.
Name the file something like ./scripts/cleanup-old-pre-commit-hook.sh
and call this in your postinstall script:
"posinstall": "./scripts/cleanup-old-pre-commit-hook.sh",
from pre-commit.
Related Issues (20)
- Add environment variable
- doesn't work with vue-cli v3.x HOT 1
- Error on windows commit (hook: line 49: : command not found) HOT 9
- Document how to turn this off permanently HOT 3
- install.js doesn't work with link file of .git.
- Question: Prevent pre-commit hook to continue on committing? HOT 5
- Does not find correct root. HOT 1
- Doesn't find git root when inside a submodule
- Commit f25888f doesnt seem to have been pushed to npm
- How to make pre-commit works just with npm ci?
- can't find any error detail HOT 1
- How to run pre-commit hook in docker container?
- make it compatible with yarn pnp
- [Bug] pre-commit don't work HOT 1
- pre-commit
- chmod 777 breaks CIS 6.1.10 (ensure no world writable files)
- [BUG] Install with --force Flag Overwrites pre-commit.old
- Is there any relationship with pre-commit.com?
- Package maintainance HOT 4
- pre-commit hook not working on macos
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pre-commit.