我已经设置了 Laravel Sail 环境,并且正在尝试使用 puppeteer 将网页另存为 pdf。
我目前正在使用这个包通过 laravel 运行 puppeteer - https://packagist.org/packages/spatie/browsershot
要求部分指定您需要通过 npm 下载 puppeteer。
Laravel Sail 有 npm 设置,所以我安装了 puppeteer 包,但是当我尝试将网页另存为屏幕截图时,出现以下错误
The command "PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node '/var/www/html/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"https:\/\/google.com","action":"screenshot","options":{"type":"png","path":"\/var\/www\/html\/storage\/app\/public\/screenshot.png","args":[],"viewport":{"width":800,"height":600}}}'" failed. Exit Code: 1(General error) Working directory: /var/www/html/public Output: ================ Error Output: ================ Error: Could not find expected browser (chrome) locally. Run `npm install` to download the correct Chromium revision (856583). at ChromeLauncher.launch (/var/www/html/node_modules/puppeteer/lib/cjs/puppeteer/node/Launcher.js:80:27) at async callChrome (/var/www/html/vendor/spatie/browsershot/bin/browser.js:69:23)
它基本上说它找不到我的本地版本的铬,我不知道如何解决这个问题,如果它不是通过 docker 运行,我可以在本地安装它并指向它,但我不认为这是使用 docker 时的最佳解决方案。