node.jsgitnpmhuskygit-husky

sh: husky: command not found


I've setup a node project with husky but when my collegue tries to run npm install on his Mac he gets the following error :

noa-be@1.0.0 prepare
husky install

sh: husky: command not found
npm ERR! code 127
npm ERR! path /Users/X/Desktop/Workspace/project
npm ERR! command failed
npm ERR! command sh -c husky install

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/X/.npm/_logs/2021-04-12T13_07_25_842Z-debug.log

These are the relevant package.json parts:

{
    "scripts": {
        "prepare": "husky install"
    },
    "devDependencies": {
        "husky": "^5.2.0",
    }
}

I thought this would be enough for husky to be installed when running npm install, but it's not. What am I missing?


Solution

  • I've been able to solve the problem by upgrading to latest Husky version (7.0.1, from 5.2.0).

    Git was also helpful, and told me that the files weren't executables. (Git V 2.24.1)

    So I give them executable rights :

    chmod +x PATH_TO_HUSKY_FILE
    

    You'll need to execute this command for every hooks