It seems like the issue might be related to the path of the Node.js binary. Instead of using the setNodeBinary method, try setting the path to the Node.js binary directly in your system's environment variables.
Here are the steps to do this on Windows:
- Open the Start menu and search for "Environment Variables".
- Click on "Edit the system environment variables".
- Click on the "Environment Variables" button.
- Under "System Variables", find the "Path" variable and click "Edit".
- Click "New" and add the path to the directory containing the Node.js binary (e.g.
C:\Program Files\nodejs). - Click "OK" to close all the windows.
After setting the path, try running the code again without using the setNodeBinary method.
If that doesn't work, try running the code with the no-sandbox option:
Browsershot::html('<h1>Test</h1>')->noSandbox()->pdf();
If none of these solutions work, it might be worth checking the Spatie Browsershot documentation and GitHub issues for any known issues or solutions specific to your setup.