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

400
Views
How do I correctly launch a shell environment with node-pty in Electron?

I have an Electron App that's using node-pty to create a pseudo-terminal instance. This instance is created as follows:

const pty = require('node-pty');
const os = require('os');
const shell = process.env[os.platform() === 'win32' ? 'COMSPEC' : 'SHELL'];
const ptyProcess = pty.spawn(shell, [], {
  name: 'xterm-color',
  cols: 100,
  rows: 40,
  cwd: process.env.HOME,
  env: process.env
}); 

When I launch the app from the vscode terminal using (electron .) everything works as expected. I.e. the shell can find all programs just like it would in cmd.exe or Terminal.app.

However, if I build the app, and open it via double clicking on it, I notice that my path does not contain certain directories such as /usr/local/bin/, which can cause certain programs (like brew) to fail with "Not found" errors.

Notably, if I launch the electron app from a terminal on mac using open -a MyElectronApp everything works as expected.

I suspect my app needs to initialize the path differently somehow. However, since this is a cross-platform app, I'd like to avoid doing anything like "if os.platform == 'darwin' load /etc/paths".

Any help would be greatly appreciated. Please let me know if you need more information. I assume my issue is probably due to a misunderstanding/ignorance of shell environments!

about 4 years ago · Juan Pablo Isaza
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!