I am developing a web application using the Laravel framework. I need to generate the web page into pdf/ image in my application. I am using PHP browser shot spatie package for it, https://github.com/spatie/browsershot. I created a test function to generate the image using it with the following code.
\Spatie\Browsershot\Browsershot::url("https://www.google.com/")->save(public_path() . '/example.png');
When I run the function, I got the following error.
The command "PATH=$PATH:/usr/local/bin NODE_PATH=`npm root -g` node '/var/www/vendor/spatie/browsershot/src/../bin/browser.js' '{"url":"https:\/\/www.google.com\/","action":"screenshot","options":{"type":"png","path":"\/var\/www\/public\/example.png","args":[],"viewport":{"width":800,"height":600}}}'" failed. Exit Code: 127(Command not found) Working directory: /var/www/public Output: ================ Error Output: ================ sh: 1: npm: not found sh: 1: node: not found
I am using Docker and Docker Compose for my project. What is wrong with my code?