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

231
Visualizações
Node not reconized with Git hook on windows

I am setting up a precommit hook on an existing electron project (on Windows) using Husky (7.0.0). To install Husky I followed the documentation (here) and the .husky folder was correctly created with the two files: husky.sh

#!/bin/sh
if [ -z "$husky_skip_init" ]; then
  debug () {
    if [ "$HUSKY_DEBUG" = "1" ]; then
      echo "husky (debug) - $1"
    fi
  }

  readonly hook_name="$(basename "$0")"
  debug "starting $hook_name..."

  if [ "$HUSKY" = "0" ]; then
    debug "HUSKY env variable is set to 0, skipping hook"
    exit 0
  fi

  if [ -f ~/.huskyrc ]; then
    debug "sourcing ~/.huskyrc"
    . ~/.huskyrc
  fi

  export readonly husky_skip_init=1
  sh -e "$0" "$@"
  exitCode="$?"

  if [ $exitCode != 0 ]; then
    echo "husky - $hook_name hook exited with code $exitCode (error)"
  fi

  exit $exitCode
fi

and pre-commit:

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm test

So now before commiting the test script should be run (the test script consists just in running jest, i.e. "test":"jest"). But when I run git commit (from terminal) it fails with this output: console output. The error message states that git is not able to find node, but what it looks really strange are the first two lines of the ouput, which are suggesting that jest actually run. I am using node 18.0.0 (managed via nvm-windows) and npm 7.24.2 (these two are confirmed both in windows terminal and in git bash). The path to node is already in my $PATH environment variable. Please let me know if I can add any detail

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

That was reported before (typicode/husky issue 980), referring to the "Command not found" documentation

If your ~/.huskyrc content is correct, the path should be set.

Check that be replacing, in your pre-commit, npm test by echo $Path (inspired by issue 462).

about 4 years ago · Juan Pablo Isaza Relatório

0

I found my problem, I had a double quotes in my environment variables list that was invalidating all the following paths (among which there was the nodejs path). To understand this thing I manually ran the commands thorugh the git bash and listed the PATH env variable. Anyway there is still something that I am not able to understand, in the git bash if i ran npm -v it showed the correct node version, but trying to run other commands caused error

about 4 years ago · Juan Pablo Isaza 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