Answer the question
In order to leave comments, you need to log in
Why is child_process node.js not working?
There is a node file
var spawn = require('child_process').spawn;
var phantom = spawn('phantomjs', [ 'snapshot.js', 'http://localhost:3000/#/index/', 'index']);
phantom.on('exit', function(code, signal) {
if (code !== 0) {
return cb(new Error('Exit code is not 0: ' + code));
}
cb();
});
var page = require('webpage').create();
var system = require('system');
var fs = require('fs');
var url = system.args[1];
var name = system.args[2];
page.open(url, function () {
fs.write('snapshot/'+name+'.html', page.frameContent, 'w');
phantom.exit();
});
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn prg ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
at Function.Module.runMain (module.js:503:11)
at startup (node.js:129:16)
at node.js:814:3
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question