Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

91
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda