首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Webshot在DigitalOcean Ubuntu14.04的流星上失败

Webshot在DigitalOcean Ubuntu14.04的流星上失败
EN

Stack Overflow用户
提问于 2016-02-04 00:44:42
回答 1查看 408关注 0票数 6

我使用下面的代码来生成pdf:

代码语言:javascript
复制
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();

但它会抛出以下错误:

代码语言:javascript
复制
{ [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时没有:

代码语言:javascript
复制
fs.readFile(fileUri, function (err, data) {
  if (err) {
    return console.log(err);
  }

  fs.unlinkSync(fileUri);
  fut.return(data);
});

文件未创建..

编辑-2:

Webshot抛出错误:[Error: PhantomJS exited with return value 2]

编辑-3:实际问题:https://github.com/brenden/node-webshot/issues/123

EN

回答 1

Stack Overflow用户

发布于 2016-02-20 03:23:44

我也遇到了类似的问题,我花了一整天的时间试图弄清楚这个问题。我最后加了一句:

代码语言:javascript
复制
"phantomPath": "/usr/bin/phantomjs"

添加到我的网页截图选项对象。我使用的phantom路径是mup在服务器设置上安装phantomjs的位置。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35182835

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档