Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Windows temp path fixed #858

Merged
merged 1 commit into from
Jul 3, 2024
Merged

Conversation

SyedMuradAliShah
Copy link

I add the required ENV variables for Windows to fix the following error.

Error: ENOENT: no such file or directory, mkdtemp 'undefined\temp\puppeteer_dev_chrome_profile-XXXXXXXXXXXX'

It always occurs when you if don't pass these ENV in the Process

            "LOCALAPPDATA" => getenv("LOCALAPPDATA"),
            "Path"         => getenv("Path"),
            "SystemRoot"   => getenv("SystemRoot"),
            "USERPROFILE"  => getenv("USERPROFILE"),

I was inspired by Can't get Browsershot to work on Windows with XAMPP, few different errors

Browsershot works fine on Linux machines, but it was a challenging task to make it work on Windows, which is finally done.

I test these and its working fine.

Browsershot::html('<h1>Hello World</h1>')
        ->setNodeBinary('C:\\laragon\\bin\\nodejs\\node.exe')  // Complete path to node
        ->setNpmBinary('C:\\laragon\\bin\\nodejs\\npm.cmd') // Complete path to npm
        ->setChromePath('C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe') // Complete path to chrome
        ->save('example.pdf');
Browsershot::url('https://example.com')
        ->setNodeBinary('C:\\laragon\\bin\\nodejs\\node.exe')  // Complete path to node
        ->setNpmBinary('C:\\laragon\\bin\\nodejs\\npm.cmd') // Complete path to npm
        ->setChromePath('C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe') // Complete path to chrome
        ->save('example.pdf');

@freekmurze freekmurze merged commit 0686b84 into spatie:main Jul 3, 2024
1 of 5 checks passed
@freekmurze
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants