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

92
Visualizações
Node.JS Child Process Change Type of Terminal

I'm using the Node JS child process to execute terminal commands and get the output of them, which is all going great. However, I'm on a WSL Windows machine, and I would like to change the type of the child processes terminal to zsh.

Below is my current code for executing a command and receiving the output.

async function execute(
    command: string,
    cwd: string,
): Promise<{ output: string; error: string }> {
    const out = await promisify(exec)(command, { cwd: cwd });

    const output = out.stdout.trim();
    const error = out.stderr.trim();

    return { output: output, error: error };
}

How can I change the type of the terminal from command prompt to zsh?

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

0

you can do this

exec(command , { shell : "zsh" })

you can read more about shell requirements here : https://nodejs.org/api/child_process.html#shell-requirements

So your code should look like this :

async function execute(
    command: string,
    cwd: string,
): Promise<{ output: string; error: string }> {
    const out = await promisify(exec)(command, { cwd: cwd , 
    shell:"zsh"});

    const output = out.stdout.trim();
    const error = out.stderr.trim();

    return { output: output, error: 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