question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

exec doesn't work in electron

See original GitHub issue

Node version:

6.2.0

ShellJS version

0.7.0

Operating system:

Mac

Description of the bug:

I am trying to run the following command (that I copied from docs) in my electron console.

image

Any idea, why this would be having. As I want to return the version number for checks. Other commands such as which are working but just exec

Thank you! 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:38 (22 by maintainers)

github_iconTop GitHub Comments

5reactions
hazim-jcommented, Jun 27, 2018

setting exec to async seems to work.

let command = shell.exec('command', {silent:true, async:true});
command.stdout.on('data', (data) => {
    /* ... do something with data ... */
});
command.stdout.on('finish', () => {
    /* ... do something when finished ... */
});
5reactions
rustinpythoncommented, May 10, 2018

@nfischer Hi, glad to see there is a workaround. Tried this in an electron app and got failed after throwing an error

        var shell = require('shelljs');
        let nodePath = (shell.which('node').toString());
        shell.config.execPath = nodePath;
        shell.exec('git');

May I know is there a compatible library version to make this work? Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot execute shell command from Electron packaged app
I want to execute an python application only by name from Nodejs module called child_process. When the application isn't packaged it works, but ......
Read more >
Quick Start | Electron
This guide will step you through the process of creating a barebones Hello World app in Electron, similar to electron/electron-quick-start.
Read more >
Child process | Node.js v19.3.0 Documentation
The child_process.execFile() function is similar to child_process.exec() except that it does not spawn a shell by default. Rather, the specified executable file ...
Read more >
Common Configuration - electron-builder
Works when npmRebuild is set to true . Resolving to false will skip dependencies install or rebuild. If provided and node_modules are missing,...
Read more >
Dynamically Execute JavaScript in ElectronJS - GeeksforGeeks
For Electron to work, node and npm need to be pre-installed in the system. ... In case, the executed code does not return...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found