A solution to EACCES when launching Puppeteer
Puppeteer is a very handy way to drive Chrome headless from Node scripts. On a recent project, I had it working fine in dev but it died on deployment to production with:
Puppeteer failed with: { Error: spawn EACCES
Recording the solution here, in case it helps someone else: the issue was Puppeteer not finding the Chrome executable. We deploy on Ubuntu, so for me the solution was:
const browser = await puppeteer.launch({
executablePath: '/usr/bin/chromium-browser',
headless: true,
});