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

265
Visualizações
Which shell npm is using when running npm scripts?

I am on Windows running fish shell through ConEmu. Fish by default doesn't recognize "&&" operator however having this:

"scripts": {
  "test": "echo 'a' && echo 'b'"
}

and running "npm run test" is working. So I thought it must be using default "cmd" and this is what npm config ls -l | grep shell says, however.... When I change "test" script to:

"scripts": {
  "test": "echo 'a' && ls"
}

this also works while ls is clearly not supported in "cmd".

What the hell is going here? 😲

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

0

Looks line npm run sends the command to the sh shell, which usually points to the default Bourne-compatible shell. I don't have experience with your emulator, but I would bet it's using bash in your environment (since Fish is not Bourne-compatible).

over 4 years ago · Santiago Trujillo Relatório

0

I don't know what shell is used in your case, nor what is the preferred way to check which shell is npm using, but I have some general hints, which might help.

You can try

{ 
  "scripts": {
    "test": "echo $0" 
  }
}

which can produce results like:

$ npm run test

> @ test /home/matmat/test
> echo $0

sh

(for bash on linux)

or

C:\Users\qbolec\Documents\test>npm run test

> @ test C:\Users\qbolec\Documents\test
> echo $0

$0

on Windows Node.js command prompt.

You could also try

  "test": "which ls"

to get some more info.

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