Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!