Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

3K
Visualizações
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?

over 4 years ago · Santiago Trujillo
4 Respostas
Responde à pergunta

0

I believe it could be version specific issue. Install version 6, npm i husky@6.0.0 --save-dev, and it should work as the husky doc says.

Apparently, when I did npm i husky --save-dev, it was installing "husky": "^0.8.1" for me for some strange reason, giving me the exact same error: sh: husky: command not found.

Method 1:

Update manually, in your package.json:

{
    "scripts": {
        "prepare": "husky install",
        "create-hook": "husky add .husky/pre-commit \"npm test\"",
    }
}

Then, run npm run prepare && npm run create-hook.

It should create .husky directory with .pre-commit file in it.

Method 2:

npx husky install

npm set-script prepare "husky install"

npx husky add .husky/pre-commit "npm test"

over 4 years ago · Santiago Trujillo Relatório

0

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

over 4 years ago · Santiago Trujillo Relatório

0

I was struggling with the same exact problem for hours. Finally, I could install dependencies and start working on my project by doing this:

  1. Temporarily remove the "prepare": "husky install" script from the package.json file.
  2. Run npm i (npm install). Dependencies installed successfuly.
  3. Add again the "prepare" script that you removed in step 1.
  4. Run again npm i to install the husky git hooks, so husky can do its job from now on.
over 4 years ago · Santiago Trujillo Relatório

0

This error is also thrown by npm ci if the NODE_ENV is set to "production" pre-install

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda