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

211
Views
How do you spawn a child process in an external folder?

I'm using Electron.js to build a browser application that hooks up to a flask back-end located in a separate folder in the directory. As of now, I'm using a hacky work-around to exec the back-end:

const bat = cp.exec("cd api && python app.py");

however I would ideally like to spawn a back-end child process in the API folder. How can I do that?

Thanks

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

0

The child_process.exec() function has a specific option for the current working directory for the child process.

You can see it in the doc.

child_process.exec(command[, options][, callback])

    command <string> The command to run, with space-separated arguments.

    options <Object>
        cwd <string> | <URL> Current working directory of the child process. Default: process.cwd().
        ...

So, you can just set that option and specify the api directory:

const bat = cp.exec("python app.py", {
    cwd: path.join(process.cwd(), "api")
});
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!