spiritix / php-chrome-html2pdf

A PHP library for converting HTML to PDF using Google Chrome
MIT License
112 stars 29 forks source link

Binary error: Puppeteer old Headless deprecation warning #65

Closed Niyiojeyinka closed 7 months ago

Niyiojeyinka commented 9 months ago
Spiritix\Html2Pdf\ConverterException
Binary error: 
  Puppeteer old Headless deprecation warning:
    In the near future `headless: true` will default to the new Headless mode
    for Chrome instead of the old Headless implementation. For more
    information, please see https://developer.chrome.com/articles/new-headless/.
    Consider opting in early by passing `headless: "new"` to `puppeteer.launch()`
    If you encounter any bugs, please report them to https://github.com/puppeteer/puppeteer/issues/new/choose.

file:///var/www/vendor/spiritix/php-chrome-html2pdf/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:259
                    throw new Error(`Could not find Chrome (ver. ${this.puppeteer.browserRevision}). This can occur if either\n` +
                          ^

Error: Could not find Chrome (ver. 121.0.6167.85). This can occur if either
 1. you did not perform an installation before running the script (e.g. `npx puppeteer browsers install chrome`) or
 2. your cache path is incorrectly configured (which is: /var/www/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
    at ChromeLauncher.resolveExecutablePath (file:///var/www/vendor/spiritix/php-chrome-html2pdf/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:259:27)
    at ChromeLauncher.executablePath (file:///var/www/vendor/spiritix/php-chrome-html2pdf/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:204:25)
    at ChromeLauncher.computeLaunchArguments (file:///var/www/vendor/spiritix/php-chrome-html2pdf/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:97:37)
    at async ChromeLauncher.launch (file:///var/www/vendor/spiritix/php-chrome-html2pdf/node_modules/puppeteer-core/lib/esm/puppeteer/node/ProductLauncher.js:44:28)
    at async Converter.run (file:///var/www/vendor/spiritix/php-chrome-html2pdf/lib/Converter.js:35:25)
    at async file:///var/www/vendor/spiritix/php-chrome-html2pdf/index.js:23:20

Node.js v20.11.1

Pls how do i resolve this?

commentatorboy commented 8 months ago

I have the same issue as well.

Not sure what to do here.

commentatorboy commented 7 months ago

@Niyiojeyinka I have found a fix for it now.

I needed to do multiple things.

  1. have the node version to be 19.2.0 (I used nvm)
  2. composer install
  3. (if it still does not work) go to the base of the project:
    1. npx @puppeteer/browsers install chrome (or npx @puppeteer/browsers install chrome@121.0.6167.85)
    1. npm install

Not sure if the last two were in that order.

spiritix commented 7 months ago

Fixed in latest release