Run external applications from Electron


I’m building an Electron app where the user will be able to edit some config files and I would like to allow the user to select the preferred app/editor.

When I do this, I get EACCES error, which stands for “permission denied” even though the owner of the app is the user executing the command.

var child = require('child_process').execFile;

execFile('/Applications/Sublime\', console.log); 

Why does this error occur and how can I overcome it? Also, if I will succeed in opening the editor how can I specify the path of the file I want to open?


Corrected snippet

var execFile = require('child_process').execFile;

execFile('/Applications/Sublime\', console.log);


Use spawn.

import { spawn } from 'child_process'
const cmd = command[0]
const args = command[1]

const p = spawn(cmd, args)
p.stdout.on('data', (data) => {
  console.log('stdout: ' + data)

p.stderr.on('data', (data) => {
  console.log('stderr: ' + data)

p.on('close', (code) => {
  console.log('child process exited with code ' + code)


As for Sublime, the command would be:
/Applications/Sublime [file]:[line]


Thanks @dperetti!

I was looking for a generic solution but I realize there isn’t one. Each editor receives parameters in it’s own way.