brenden / node-webshot

Easy website screenshots in Node.js
2.12k stars 286 forks source link

Error: spawn ENOENT #101

Closed wll closed 9 years ago

wll commented 9 years ago

code: webshot(pageUrl, options,function(err, renderStream) { var path = ["public/images",dateFormat(now, "isoDate")].join("/") var fileName = randomString(16) + ".png" if (!fs.existsSync(path)) { fs.mkdirSync(path); } path = [path, fileName].join("/") console.log(path) var file = fs.createWriteStream(path, {encoding: 'binary'}); console.log(file) renderStream.on('data', function(data) { file.write(data.toString('binary'), 'binary'); }); renderStream.on('end', function(dt) { res.json({"url": path.replace("public/", "")}) }); });

log message: { _writableState: { highWaterMark: 16384, objectMode: false, needDrain: false, ending: false, ended: false, finished: false, decodeStrings: true, defaultEncoding: 'utf8', length: 0, writing: false, sync: true, bufferProcessing: false, onwrite: [Function], writecb: null, writelen: 0, buffer: [], errorEmitted: false }, writable: true, domain: null, _events: { finish: { [Function: g] listener: [Function] } }, _maxListeners: 10, path: 'public/images/2015-03-08/2J8Nxr8PakeMNfKx.png', fd: null, flags: 'w', mode: 438, start: undefined, pos: undefined, bytesWritten: 0 }

events.js:72 throw er; // Unhandled 'error' event ^ Error: spawn ENOENT at errnoException (child_process.js:1001:11) at Process.ChildProcess._handle.onexit (child_process.js:792:34)

donaldwasserman commented 9 years ago

Install phantom.js:

brew install phantomjs

See: https://github.com/brenden/node-webshot/issues/57