3

我正在尝试捕获在 localhost 中运行的网站的屏幕截图,并且我正在使用 Spatie/Browsershot。

当我尝试运行此功能时

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;
    }

弹出这个错误

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' }

我尝试将自定义路径设置为这些属性:

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

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

我还运行了 npm install puppeteer。

附加:Laravel 8 Windows 10 节点 v14.17.2

有人对我做错了什么有任何想法吗?

4

0 回答 0