Saturday, January 10, 2015

NodeFuzz: nodejs "Error: spawn ENOENT" error

ENOENT error is due to the unavailability of required command in the PATH environment variable directories.

root@darshanams:~/Downloads/NodeFuzz-0.1.1# nodejs nodefuzz.js
Loading linux-configuration.
No module folder given. Defaulting to ./modules/ from config.js
Found property init() from module ./modules//DemoCanvasModule.js
You could have some inits in DemoCanvasModule.js and it would be executed now.
Successfully required module DemoCanvasModule.js
Found property init() from module ./modules//DemoMinModule.js
Successfully required module DemoMinModule.js
Will not handle directories in module-dir. Skipping ./modules//Helpers
We have 2 modules available.
Server listening port 8080

        throw er; // Unhandled 'error' event
Error: spawn ENOENT
    at errnoException (child_process.js:1000:11)
    at Process.ChildProcess._handle.onexit (child_process.js:791:34)

Search for spawn or child_process.spawn in our NodeFuzz or Applications source code which should be of the form
    spawn(command, args)
in my case it was
        browser = spawn(config.launch_command, config.browser_args)

Add below lines on top of spawn
    console.log( process.env.PATH );
    console.log( config.launch_command );
which prints PATH environment variable values and command being used.
This is the output on my console

So the issue is with command "google-chrome", node is unable to find or execute the command. Instead of throwing the exception to stdout lets handle the exception.
     browser = spawn(config.launch_command, config.browser_args)
   browser.on('error', function (err) {
        console.log('config.launch_command error', err);


I am not a Java programmer, stuck with this error for 2 days. Googling also showns that this is a frequent error without a solution.

To fix similar issues read

Hope, this helps someone somehwhere :-)