husky: Husky failed to install with `Cannot read property 'toString' of null` message.
OS: MacOS 10.15.2 (19C57) Git: git version 2.23.0
❯ node -v v12.14.0
"husky": "^4.0.6",
During the installation i’m getting the following error.
husky > Setting up git hooks
Cannot read property 'toString' of null
husky > Failed to install
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 23
- Comments: 21 (6 by maintainers)
Commits related to this issue
- exit with 1 if husky fails to install/uninstall — committed to typicode/husky by typicode 4 years ago
Had the same error. I run in a docker container (project files are on a shared volume). I have no git in the container, this is what I get with HUSKY_DEBUG=1
husky > Setting up git hooks husky:debug Current working directory is /opt/app/node_modules/husky Cannot read property 'toString' of null husky:debug TypeError: Cannot read property 'toString' of null at Object.checkGitVersion (/opt/app/node_modules/husky/lib/installer/checkGitVersion.js:12:32) at run (/opt/app/node_modules/husky/lib/installer/bin.js:60:31) at Object.<anonymous> (/opt/app/node_modules/husky/lib/installer/bin.js:88:1) at Module._compile (internal/modules/cjs/loader.js:956:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10) at Module.load (internal/modules/cjs/loader.js:812:32) at Function.Module._load (internal/modules/cjs/loader.js:724:14) at Module.require (internal/modules/cjs/loader.js:849:19) at require (internal/modules/cjs/helpers.js:74:18) at Object.<anonymous> (/opt/app/node_modules/husky/husky.js:20:3) husky > Failed to install
Installing git into the container fixed this issue.
happened to me also. happens only during docker container build
tried to use version 2.6.0 and got this error
the .git is in the dockerignore . i also tried to remove it from there
how can I fix it ?
I think the way install git will help. But husky requiring git when build feels not necessary. Add more info here in case it helps.
I just got same error after updating husky from 4.3.0 to 4.3.4. It happens both when I try to build in Heroku, and also in the docker.
Hi @typicode
It might happen because I don’t have
git
installed in some of the Docker images that my CI uses.node:10-slim
for instance. So if thegit
version check is part of husky, maybe do it after checking if husky should be installed at all (isCI
).@typicode
With 4.3.8 I’m get ting
git --version command failed. Got null
instead.Hi @typicode
This issue seems to have been around for quite some time, but has lately received some traction. Do you have a comment on how to fix this?
Best regards Jens
Indeed, I also revert back to
husky@4.3.0
while waiting for a fix.