Reputation: 3548
I'm using GitKraken (not sure if relevant) and as I'm trying to commit, I get this error message:
And as I press the button "View Hook Output" I get the following:
pre-commit
husky > npm run -s precommit (node v8.9.4)[?25l
npm > Running tasks for src/**/*.js
\ yarn format
git add
(...lots of these two rows...)
\ yarn format
git add
"yarn format" found some errors. Please fix them and try committing again. yarn run v1.6.0 $ prettier-standard './src/**/*.js' C:\mypath\myfile.js info[Visit [0;1mhttps://yarnpkg.com/en/docs/cli/run for documentation about this comand.
prettier-eslint [ERROR] eslint fix failed due to an eslint error prettier-standard [ERROR] There was an error formatting "C:\mypath\messages.js": TypeError: Cannot read property 'range' of null
at SourceCode.getTokenBefore (c:\mypath\index.js:303:18)
at checkSpacingBefore (C:\mypath\template-curly-spacing.js:52:42)
at TemplateElement (C:\mypath\template-curly-spacing.js:117:17)
at listeners.(anonymous function).forEach.listener (C:\mypath\safe-emitter.js:47:58)
at Array.forEach (<anonymous>)
at Object.emit (C:\mypath\safe-emitter.js:47:38)
at NodeEventGenerator.applySelector (C:\mypath\node_modules\eslint\lib\utilode-event-generator.js:251:26)
at NodeEventGenerator.applySelectors (C:\mypath\node_modules\eslint\lib\util\node-event-generator.js:280:22)
at NodeEventGenerator.enterNode (C:\mypath\node-event-generator.js:294:14)
at CodePathAnalyzer.enterNode (C:\mypath\code-path-analyzer.js:608:23)
at Traverser.enter [as _enter] (C:\mypath\node_modules\eslint\lib\linter.js:865:28)
at Traverser._traverse (C:\mypath\traverser.js:132:14)
at Traverser._traverse (C:\mypath\node_modules\eslint\lib\util\traverser.js:144:34)
at Traverser._traverse (C:\mypath\node_modules\eslint\lib\util\traverser.js:147:30)
at Traverser._traverse (C:\mypath\traverser.js:144:34)
at Traverser._traverse (C:\mypath\traverser.js:147:30)
failure formatting 1 file with prettier-standard error Command failed with exit code 1.
husky > pre-commit hook failed (add --no-verify to bypass) exit
What is causing this? No one can commit anything on GitKraken or Sourcetree. Only on command line. Very strange. What might be the cause and solution to this? I've heard some comments about npm versions used by husky or yarn.
Upvotes: 8
Views: 17225
Reputation: 5758
If using husky to execute hooks in a node-based project on Windows, this issue may be relevant:
Husky: Issue with path resolution on Windows (#1397)
Check the version of husky you currently have installed in your project:
npm ls jusky
If the version is prior to v9.1.0, then update the package:
npm update husky
Then re-install your git hooks:
npx husky install
Upvotes: 0
Reputation: 5354
From GitKraken:
Some advanced hooks may rely on features not included in GitKraken's bundled minimal Git install. You can select a full Git install for GitKraken to use from Preferences > Experimental > Git Executable after downloading and installing Git from https://git-scm.com/download/win.
Upvotes: 4
Reputation: 1
I recently just solved this on a nodejs project i forked from by removing anything precommit was.
Using visual studio you need to be in solution explorer and show all files otherwise they will be hidden.
Upvotes: 0
Reputation: 450
I was having the same issue but managed to temporarily fix it by removing the precommit npm module, be mind full this is not the ideal way as precommit runs the test scripts before the code is pushed to your repository.
use below command to remove recommit. npm remove precommit
Upvotes: 2