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

228
Vistas
how to open node in a new terminal from cmd?

when I type start node into the cmd it starts up a new node terminal like this:

but how do I get it to run a script in the node terminal and close it after it's done?

maybe something like this?

start node "index.js" (when I try this it opens a terminal then immediately closes)

index.js:

console.log('hello there!');

await new Promise(r=>setTimeout(r,3000));
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Top-level awaits aren't supported in Node versions prior to 14.18.0; there is a helpful discussion on GitHub as to why.

Since you're running v14.17.6, you'll need to wrap your code in an anonymous async function, then invoke it with ():

(async () => {
    console.log('hello there!');
    await new Promise(r=>setTimeout(r,3000));
})();

The resulting Node terminal will await for your timeout period before being closed.

(It may also behoove those reading this answer to ensure that they are correctly referencing the script they wish to execute relative to their command line's current working directory; see comment below by @cakelover.)

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