Electron Error: After packaging app; Error: spawn C:\Windows\system32\cmd.exe ENOENT


#1

Error: spawn C:\Windows\system32\cmd.exe ENOENT

This may be a stupid question for most of you but being a newbie I am struggling with it a lot. Please help.

I have following code in my main process of electron

...
 var exec = require('child_process').spawn;
child = exec( __some_command__,{cwd: __dirname + '/Ant_Build'}, function(error, stdout, stderr) {
                        console.log('stdout: ' + stdout);
                        console.log('stderr: ' + stderr);
                        if (error !== null) {
                            console.log('exec error: ' + error);
                            // event.returnValue='ERROR';
                             event.sender.send('asynchronous-reply', 'ERROR');
                        }
                        // event.returnValue='OK';
                        event.sender.send('asynchronous-reply', 'OK');
                        });
...

While running locally(without building a installer) it works fine but when I build distribution(.exe) and install it on some other PC I am getting this error in console:

Error: spawn C:\Windows\system32\cmd.exe ENOENT

I search about this error but only solution I got is check the path variable and if its not contains C:\Windows\system32 then include it. But path variable already has it included.

PS: I am using Windows 10.

Thanks in Advance.


#2

That looks like the wrong parameters for spawn? Maybe there are different versions. Anyway, probably the specified cwd does not exist on the other PC.


#3

Thanks @discordchris. It was really a “does not exist directory” error, as the directory was in app.asar archive for which the cmd.exe will not work.