Is it possible to run the full npm puppeteer node package on Netlify. I am deploying a Next.js 13 site and need to call puppeteer from an api route. I am not using a Netlify Function or AWS lambda. This works fine locally but when I deploy to Netlify I get the following (popular) error:
error: Error: Could not find Chrome (ver. 117.0.5938.88). This can occur if either
1. you did not perform an installation before running the script (e.g. `npm install`) or
2. your cache path is incorrectly configured (which is: /home/sbx_user1051/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
I tried to change the .cache to a folder within my project as suggested by the docs with the following config in .puppeteerrc.cjs. in my project root:
const { join } = require('path');
/* console.log('Puppeteer config loaded');
console.log(
'Puppeteer cache directory:',
join(__dirname, '.cache', 'puppeteer')
); */
module.exports = {
// Changes the cache location for Puppeteer.
cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
};
Locally, this does create a .cache file in the project dir but I still get the same error with the same cache path stated - it seems to ignore the config file.
I have only seen others trying to run puppeteer as a lambda/netlify function so firstly is it possible to run the full puppeteer package as opposed to puppeteer-core and if so can anyone advise how you are supposed to configure it for Netlify. This is my first time using Netlify so I'm not very familiar with their setup unfortunately. Thanks in advance!
The better the post - the faster the answer.