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(); }); And there is a snapshot.js file that runs through the file above.
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(); }); Both files are in the same directory. If you run the phantome.js file separately, then everything works. But starting with a child process I get an error:
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