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

117
Visualizações
Node execute PS script prepends options that fail

exec('command', {'shell':'powershell.exe'}, (error, stdout, stderr) => { ... } fails with the following error:

/d : The term '/d' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ /d /s /c command
+ ~~
    + CategoryInfo          : ObjectNotFound: (/d:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

What is prepending the /d /s /c and how can it be prevented?

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

0

  • Your symptom implies that you're using an old Node.js version.

  • Upgrade to at least v11.15.0 to make your code work.

In versions before that, the command-line options /d /s /c were invariably used, irrespective of what executable you specified for shell - and since powershell.exe doesn't understand these options, commands invariably failed.

Since v11.15.0, -c is now used for any shell other than cmd.exe, which PowerShell does understand.

You can use the following test command from PowerShell to see if your Node.js version is recent enough:

# Run from PowerShell.
# If your Node.Js version is recent enough, you'll see PowerShell's version info,
# otherwise, an error will occur.
node -pe "child_process.execSync('`$PSVersionTable', { shell: 'powershell.exe' }).toString()"
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