I'm trying to use Puppeteer and BrowserShot on an Ubuntu machine to make and screenshot of a static HTML.
The thing is that every time I try to make and screenshot:
Screenshot::loadView('monthly_resume.resume')
->waitUntilNetworkIdle(true)
->windowSize(1200, 630)
->noSandbox()
->storeAs($this->pathFor($user), 'image.php');
It returns an error. It seems that the HTML it's stored properly under a folder inside /tmp
, in this case tmp/441150534-0230735001662479158/index.html
.
But when node tries to find it says that the file it's not found even when it's there. Any idea why node can't find it?
Symfony\Component\Process\Exception\ProcessFailedException
The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATH=`npm root -g` node '/home/forge/monse.app/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"file:\/\/\/tmp\/441150534-0230735001662479158\/index.html","action":"screenshot","options":{"type":"png","path":"\/tmp\/1562301876-0230606001662479158\/BrowsershotOutput1662479158hbgfB.png","args":["--no-sandbox"],"viewport":{"width":1200,"height":630},"displayHeaderFooter":false,"waitUntil":"networkidle0"}}'" failed.
Exit Code: 1(General error)
Working directory: /home/forge/monse.app
Output:
================
Error Output:
================
Error: net::ERR_FILE_NOT_FOUND at file:///tmp/441150534-0230735001662479158/index.html
at navigate (/home/forge/node_modules/puppeteer/lib/cjs/puppeteer/common/Frame.js:225:23)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Frame.goto (/home/forge/node_modules/puppeteer/lib/cjs/puppeteer/common/Frame.js:195:21)
at async Page.goto (/home/forge/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:1143:16)
at async callChrome (/home/forge/monse.app/vendor/spatie/browsershot/bin/browser.js:249:26)
I encountered exact error message that you got. But then I just change temp path and its working fine. I'm using spatie/browsershot
by the way
To change temp path at spatie/browsershot
:
Browsershot::html('some html string')
->setCustomTempPath('/home/your/other/path')
->save('filename.jpg')