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

298
Visualizações
Why aren't NPM scripts relaying arguments correctly on Windows PowerShell?

Been vexed by this all day. Using Powershell 7.2

Given script index.js with this single line

console.log(process.argv);

And a package.json of

{
  "scripts": {
    "index": "node index.js"
  }
}

When I invoke this command:

node index -a -b -c

Then I see

[
  'C:\\nodejs\\node.exe',
  'C:\\Users\\michael.morris\\Projects\\Fleetcor\\ucx-cucumber\\index.js',
  '-a',
  '-b',
  '-c'
]

And when I run

npm run index -- -a -b -c

Then I should get the same output, but I don't. The -a -b -c args are gone. The -- should prevent that.

This really sucks. I have to be doing something wrong right?

Node v14.15.5, NPM 8.1.3

EDIT: The mystery deepens. I decided to try this across different shells. The above behavior was on PowerShell 7.2 running stand alone since I don't have admin permissions on this machine. I tried PS 5 which came with the machine, same problem. So I went to the command prompt - and it worked as it should...

So I can proceed with my work, but it would help to know exactly what's up or if this is a bug of some sort.

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