Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aoualmiaabdou's avatar

Spatie/laravel-pdf throw an error in laravel cloud

helo, i try to add pdf generation functionality to my filament dashboard, how ever in my local server everything is fine, but when i deploy the project to laravel cloud this error poop out when i try to generate a pdf :

The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATH=`npm root -g` node '/var/www/html/vendor/spatie/browsershot/src/../bin/browser.cjs' '{"url":"file:\/\/\/tmp\/1327532565-0579267001753106813\/index.html","action":"pdf","options":{"args":[],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"format":"a4","printBackground":true}}'" failed. Exit Code: 1(General error) Working directory: /var/www/html/public Output: ================ Error Output: ================ node:internal/modules/cjs/loader:1401 const err = new Error(message); ^ Error: Cannot find module 'puppeteer' Require stack: - /var/www/html/vendor/spatie/browsershot/bin/browser.cjs at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15) at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19) at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22) at Function._load (node:internal/modules/cjs/loader:1211:37) at TracingChannel.traceSync (node:diagnostics_channel:322:14) at wrapModuleLoad (node:internal/modules/cjs/loader:235:24) at Module.require (node:internal/modules/cjs/loader:1487:12) at require (node:internal/modules/helpers:135:16) at callChrome (/var/www/html/vendor/spatie/browsershot/bin/browser.cjs:70:28) at Object.<anonymous> (/var/www/html/vendor/spatie/browsershot/bin/browser.cjs:441:5) { code: 'MODULE_NOT_FOUND', requireStack: [ '/var/www/html/vendor/spatie/browsershot/bin/browser.cjs' ] } Node.js v22.17.0
1 like
7 replies
nomadicinsights's avatar

So our team is on Laravel Cloud and it's got a lot of quirks. I'd recommend connecting to Nightwatch since the tracing is much better that way. Looking at this it looks like your Node package isn't updating correctly so there is probably an issue with your deployment script.

Are you using Docker/Sail for your local?

racl101's avatar

Error: Cannot find module 'puppeteer'...

That sounds like the deployment script / pipeline script has not ran npm install on the directory containing the the package.json that includes puppeteer as a dependency.

aoualmiaabdou's avatar

@racl101 @racl101 yes i thought this at beginning , but when i run npm install new error shown :

The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATH=`npm root -g` node '/var/www/html/vendor/spatie/browsershot/src/../bin/browser.cjs' '{"url":"file:\/\/\/tmp\/2082586733-0053253001753135084\/index.html","action":"pdf","options":{"args":[],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"format":"a4","printBackground":true}}'" failed. Exit Code: 1(General error) Working directory: /var/www/html/public Output: ================ Error Output: ================ Error: Failed to launch the browser process! /var/www/.cache/puppeteer/chrome-headless-shell/linux-133.0.6943.98/chrome-headless-shell-linux64/chrome-headless-shell: 1: c�: not found /var/www/.cache/puppeteer/chrome-headless-shell/linux-133.0.6943.98/chrome-headless-shell-linux64/chrome-headless-shell: 2: %@@@����������: not found /var/www/.cache/puppeteer/chrome-headless-shell/linux-133.0.6943.98/chrome-headless-shell-linux64/chrome-headless-shell: 3: ��I: not found /var/www/.cache/puppeteer/chrome-headless-shell/linux-133.0.6943.98/chrome-headless-shell-linux64/chrome-headless-shell: 4: ��I: not found /var/www/.cache/puppeteer/chrome-headless-shell/linux-133.0.6943.98/chrome-headless-shell-linux64/chrome-headless-shell: 2: @8@: not found

however when i take some time then i re-try to generate the first error will return !!!

racl101's avatar

@aoualmiaabdou > Error: Failed to launch the browser process! /var/www/.cache/puppeteer/chrome-headless-shell/linux-133.0.6943.98/chrome-headless-shell-linux64/chrome-headless-shell:

That could mean you may be missing the chrome / chromium browser. As you know, one of the main reasons to install Puppeteer is to run a headless browser in order to leverage its PDF generating capabilities.

So that means you need to install the chrome browser as a dependency on the server you are running it on.

In fact, the Puppeteer page lists all the dependencies you need to install on Linux for it to run:

https://pptr.dev/troubleshooting#chrome-doesnt-launch-on-linux

aecioneto's avatar

Did you find any solution? I'm trying the same thing, but it did not work.

I think I will need to use dompdf.

Please or to participate in this conversation.