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

275
Vistas
How to run a cmd command in the current Terminal

I have a simple issue involding child_proccess. If you call child_process from a script its going to run that command in that script. If you export a function that runs the command, for what i've tested, it tries to run the command in the library terminal and not the current terminal. Example: Lets say you have your script a.js that you export to b.js and in a.js you have this function called hello that prints "Hello World" with the echo command:

//a.js
export function hello(){
  child_process.execSync("echo Hello World");
}
import {hello} from "a.js"
hello();

When you run it it will not send you anything. If you print "Hello World" with console.log() it will return it in the current terminal. Is there a way to execute a cmd command in the current terminal?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The command is actually running on the same terminal. Since you have not asked the child_process to direct the stdout to the current terminal, it does not print anything.

//a.js
export function hello(){
  child_process.execSync("echo Hello World",{stdio:"inherit"});
}

This should work fine.

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