1

I need to start the electron.js application programically. Below solution with execa library works, however I did not find the answer, how to make console to display console.log() inside InitializeProject_GUI.js (here is that question).

import executeExternalCommand, { ExecaReturnValue } from 'execa';

const executionResult: ExecaReturnValue<string> = await executeExternalCommand(
    'electron',
    ['InitializeProject_GUI.js'],
    { cwd: __dirname }
);

So I decided to use standard child_process instead. Maybe it will be easier to find how to display console.log()'s of child process, but first I need to make electron application start.

import ChildProcess, { ChildProcess as ChildProcess__type } from 'child_process';

const childProcess: ChildProcess__type = ChildProcess.spawn(
    'electron',
    ['InitializeProject_GUI.js'],
    { cwd: __dirname }
);

I got Error: spawn electron ENOENT:

enter image description here

Also, ChildProcess.exec('electron InitializeProject_GUI.js', { cwd: __dirname }); do NOTHING.

And, ChildProcess.execSync('electron InitializeProject_GUI.js', { cwd: __dirname }); causes the error with broken encoding:

enter image description here

Takeshi Tokugawa YD
  • 670
  • 5
  • 40
  • 124
  • Concertized question in [How to execute locally installed Node.js application by child_process.spawn()? ](https://stackoverflow.com/questions/56732419/how-to-execute-locally-installed-node-js-application-by-child-process-spawn). – Takeshi Tokugawa YD Jun 24 '19 at 08:18

0 Answers0