Laravel Spatie Browsershot errno: -4058, code: 'ENOENT'

1.4k Views Asked by At

I am trying to capture a screenshot of my website running in localhost and i am using Spatie/Browsershot.

When i try to run this function

public function receipt(){
        $image = Browsershot::url('http://localhost:8000/transaction/receipt/123')
        ->setNodeBinary('C:\Users\\my_user\\nodejs\\node.exe')
        ->setNpmBinary('C:\Users\\my_user\\nodejs\\npm.exe')
        ->base64Screenshot();

        return $image;
    }

This error popped up

Symfony\Component\Process\Exception\ProcessFailedException
The command "C:^\Users^\Abimanyu^\nodejs^\node.exe ^"D:^\laravel_projects^\teliti-core-app^\vendor^\spatie^\browsershot^\src/../bin/browser.js^" ^"^{^\^"url^\^":^\^"http:^\/^\/localhost:8000^\/transaction^\/receipt^\/123^\^",^\^"action^\^":^\^"screenshot^\^",^\^"options^\^":^{^\^"type^\^":^\^"png^\^",^\^"args^\^":^[^],^\^"viewport^\^":^{^\^"width^\^":800,^\^"height^\^":600^},^\^"executablePath^\^":^\^"C:^\^\Users^\^\Abimanyu^\^\AppData^\^\Local^\^\Google^\^\Chrome^\^\Application^\^\chrome.exe^\^"^}^}^"" failed. Exit Code: 1(General error) Working directory: D:\laravel_projects\teliti-core-app\public Output: ================ Error Output: ================ [Error: ENOENT: no such file or directory, mkdtemp 'undefined\temp\puppeteer_dev_chrome_profile-XXXXXX'] { errno: -4058, code: 'ENOENT', syscall: 'mkdtemp', path: 'undefined\\temp\\puppeteer_dev_chrome_profile-XXXXXX' }

I've tried setting the custom path to these attributes:

setChromePath("C:\Users\my_user\AppData\Local\Google\Chrome\Application\chrome.exe")

setNpmBinary('C:\Users\my_user\AppData\Roaming\npm')

I've also run npm install puppeteer.

Additional : Laravel 8 Windows 10 Node v14.17.2

Anyone any ideas on what i am doing wrong?

0

There are 0 best solutions below