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

150
Views
Open new terminal in MacOSX and run node script

I have been trying to figure out how to open a new terminal window from a Node application and run a preset command or script there.

I can open the terminal window:

const { exec } = require('child_process')

exec('open -a Terminal ' + process.env.HOME)

And this works fine, I have done a bit of research but it seems I can only find examples directed to bash

Could anyone help me on this?

Thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One way to do this would be to place the commands you want to run in a shell script with the .command extension. By default, these files will be opened in the Terminal application on macOS. This is a bit of a workaround, but I think it achieves what you would like to do.

Say we have the file hello.js containing the following:

console.log("Hello World")

And the shell script run_node.command

#!/bin/bash
node hello.js

Running the command open run_node.command will open a new Terminal.app instance and run the shell script, which in turn runs the node command. The terminal will close when the script exits.

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!