ollie_123's avatar

Browsershot Issue on Linux Server

Hi All

I've been using browsershot to create PDF's for ages but after a composer update it now throws an error on the live server but still works fine locally so a little bit confused. The error points to a path issue but its never been an issue before.

Please can someone advise where i would start on fixing this...

Here's the error

Symfony\Component\Process\Exception\ProcessFailedException · The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATH=`npm root -g` node '/home/myproject/public_html/vendor/spatie/browsershot/src/../bin/browser.cjs' '{"url":"https:\/\/www.myproject.co.uk\/proforma-pdf\/14160325ddd9b6f95da9366b8f58bf787731b1d2466be","action":"pdf","options":{"path":"\/home\/myproject\/public_html\/storage\/app\/invoices\/AM3_PF-1180.pdf","args":[],"viewport":{"width":800,"height":600}}}'" failed. Exit Code: 1(General error) Working directory: /home/myproject/public_html/public Output: ================ Error Output: ================ /home/myproject/public_html/vendor/spatie/browsershot/bin/browser.cjs:373 await page.waitForSelector(request.options.waitForSelector, request.options.waitForSelectorOptions ?? undefined); ^ SyntaxError: Unexpected token ? at Module._compile (internal/modules/cjs/loader.js:723:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

Huge thank you in advance.

0 likes
2 replies
PierreZA's avatar
PierreZA
Best Answer
Level 4

Hey there,

We had the same issue when updating our PHP version earlier. I would suggest you either:

  1. roll back your browsershot version and lock it.
  2. Update your node version to atleast 15.x

So we locked our browsershot version to 3.47 (previously it was just latest), and also tried updated node from 12.22 to 15.4 (just picked version 15 to see if it would work locally). And both worked for us. Good luck.

ollie_123's avatar

Hey @pierreza, thank you. I rolled Pupeteer & browsershot back and it seemed to play nicely again . Thanks for your help.

1 like

Please or to participate in this conversation.