I've run this to install husky:
$ npm i husky --save-dev
npm http GET https://registry.npmjs.org/husky
npm http 304 https://registry.npmjs.org/husky
> [email protected] install C:\Users\bvandermeer\Source\_\current-processes\node_modules\husky
> node ./bin/install.js
husky
setting up hooks in .git/hooks/
done
[email protected] node_modules\husky
I've added this in my package.json:
{
"scripts": {
"precommit": "node test.js"
}
}
This is the contents of test.js
:
console.log('FAILED');
process.exit(-1);
And when I try to commit I get this error:
$ git add package.json
$ git commit -m 'Added husky'
.git/hooks/pre-commit: line 4: npm: command not found
husky - pre-commit hook failed (add -n to bypass)
This is the PATH variable inside the file .git/hooks/pre-commit
, that husky added:
PATH="c:\Users\bvandermeer\.nodist\bin\node_modules\npm\bin\node-gyp-bin;c:\Users\bvandermeer\Source\_\current-processes\node_modules\husky\node_modules\.bin;c:\Users\bvandermeer\Source\_\current-processes\node_modules\.bin;C:\Users\bvandermeer\.nodist\bin\;C:\Program Files\ImageMagick-6.8.9-Q16;C:\Program Files\Python27\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Apache24\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Windows Imaging\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files (x86)\svn-win32-1.7.10\bin;C:\users\bvandermeer\strawberry-perl\c\bin;C:\users\bvandermeer\strawberry-perl\perl\site\bin;C:\users\bvandermeer\strawberry-perl\perl\bin;C:\Program Files\WinRAR\;C:\Program Files\MongoDB\bin;C:\Program Files (x86)\scala\\bin;C:\Users\bvandermeer\.nodist\bin;C:\Program Files\dart\dart-sdk\bin;C:\Ruby200\bin;C:\Program Files (x86)\WinAnt\bin;C:\Program Files (x86)\Git\bin;C:\Program Files\Java\jre7\bin;C:\Program Files\nssm;C:\Program Files\Oracle\VirtualBox"
And here are the paths as a list:
c:\Users\bvandermeer\.nodist\bin\node_modules\npm\bin\node-gyp-bin
c:\Users\bvandermeer\Source\_\current-processes\node_modules\husky\node_modules\.bin
c:\Users\bvandermeer\Source\_\current-processes\node_modules\.bin
C:\Users\bvandermeer\.nodist\bin\
C:\Program Files\ImageMagick-6.8.9-Q16
C:\Program Files\Python27\
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\Program Files (x86)\Apache24\bin
C:\Program Files (x86)\Git\cmd
C:\Program Files (x86)\Windows Imaging\
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\
C:\Program Files\Microsoft Windows Performance Toolkit\
C:\Program Files (x86)\svn-win32-1.7.10\bin
C:\users\bvandermeer\strawberry-perl\c\bin
C:\users\bvandermeer\strawberry-perl\perl\site\bin
C:\users\bvandermeer\strawberry-perl\perl\bin
C:\Program Files\WinRAR\
C:\Program Files\MongoDB\bin
C:\Program Files (x86)\scala\bin
C:\Users\bvandermeer\.nodist\bin
C:\Program Files\dart\dart-sdk\bin
C:\Ruby200\bin
C:\Program Files (x86)\WinAnt\bin
C:\Program Files (x86)\Git\bin
C:\Program Files\Java\jre7\bin
C:\Program Files\nssm
C:\Program Files\Oracle\VirtualBox
And in the case of Nodist, my npm executable (npm.cmd
on windows), is actually located here: C:\Users\bvandermeer\.nodist\bin
, which is actually twice in the PATH variable. But I don't understand why it doesn't work.
Temporary solution
If I comment the PATH="..."
line from the file .git/hooks/pre-commit
, it actually works, the output is then:
$ git commit -m 'Added husky'
FAILED
husky - pre-commit hook failed (add -n to bypass)
So, when I created pull/#5, I was trying to fix this problem. This is the commit you decided not to merge, which makes it fail on Windows: branneman@89b13e2
But as you've said before, removing the PATH
makes it fail on OSX. So we need a another solution thats cross platform.