簡體   English   中英

Webshot在DigitalOcean Ubuntu 14.04中的Meteor失敗

[英]Webshot fails on Meteor in DigitalOcean Ubuntu 14.04

我正在使用此代碼生成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然后代碼在localhost上完美運行,但在服務器上失敗並拋出此錯誤:

編輯:

即使在沒有運行webshot的情況下:

fs.readFile(fileUri, function (err, data) {
  if (err) {
    return console.log(err);
  }

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

該文件未創建..

EDIT 2:

Webshot拋出錯誤: [Error: PhantomJS exited with return value 2]

編輯3:實際問題: https//github.com/brenden/node-webshot/issues/123

我遇到了類似的問題,並且花了大部分時間試圖弄清楚問題。 我最后補充說:

"phantomPath": "/usr/bin/phantomjs"

到我的webshot選項對象。 我使用的幻像路徑是mup在你的服務器設置上安裝phantomjs。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM