安装和运行browsershots

时间:2018-05-09 09:47:05

标签: node.js npm centos

我尝试安装Brwoswershots(https://github.com/spatie/browsershot),我按照github上的说明完成了这个。

Installing NodeJS and npm via yum
Installing browswershoots via composer: composer require 
satie/browsershot

crated a file with 
use Spatie\Browsershot\Browsershot;
$pathToImage="img/testasdf.png";
// an image will be saved
Browsershot::url('https://example.com')
    ->setScreenshotType('jpeg', 100)
    ->save($pathToImage);

它位于http://textblob.com/browsershots.php并带来错误。

Fatal error: Uncaught
Symfony\Component\Process\Exception\ProcessFailedException:
The command "PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node
'/home/textblob/public_html/vendor/spatie/browsershot/src/../bin/browser.js'
'{"url":"https:\/\/example.com",
  "action":"screenshot",
  "options": {
      "type":"jpeg",
      "path":"img\/testasdf.png",
      "quality":100,
      "args":[],
      "viewport":{"width":800,"height":600}
  }
}'"
failed. Exit Code: 1(General error) Working directory:
/home/textblob/public_html

输出:================错误输出:================

/home/textblob/public_html/vendor/spatie/browsershot/bin/browser.js:5
const getOutput = async (page, request) =>
{ ^ SyntaxError: Unexpected token ( at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.runMa in /home/textblob/public_html/vendor/spatie/browsershot/src/Browsershot.php
on line 565

1 个答案:

答案 0 :(得分:0)

我可以通过降级到boxshot v2来解决这个问题,巫婆可以在没有木偶的情况下工作,所以它不是一个修复,而是为我工作。