在DigitalOcean Ubuntu 14.04中,Webshot在meteor上失败
我正在使用这个代码来生成pdf:
let fileUri = process.env.PWD + '/storage/orders-pdf/' + fileName; // Commence Webshot webshot(html_string, fileUri, options, function(error) { fs.readFile(fileUri, function (err, data) { if (err) { return console.log(err); } fs.unlinkSync(fileUri); fut.return(data); }); }); let pdfData = fut.wait();
但它会引发以下错误:
{ [Error: ENOENT, open '/opt/holi/storage/orders-pdf/Attributes.pdf'] errno: 34, code: 'ENOENT', path: '/opt/holi/storage/orders-pdf/Attributes.pdf' }
试图使用NPM包https://github.com/brenden/node-webshot然后代码在本地主机完美工作,但在服务器上失败,并引发此错误:
编辑:
即使没有运行webshot:
fs.readFile(fileUri, function (err, data) { if (err) { return console.log(err); } fs.unlinkSync(fileUri); fut.return(data); });
该文件没有创build..
EDIT 2:
Webshot引发错误: [Error: PhantomJS exited with return value 2]
编辑-3:实际问题: https : //github.com/brenden/node-webshot/issues/123
我也有类似的问题,一整天的大部分时间都在试图解决这个问题。 我最后补充说:
"phantomPath": "/usr/bin/phantomjs"
到我的webshot选项对象。 我使用的幻影path是mup在你的服务器设置上安装phantomjs的地方。