Reputation: 101
I'm working on a project that uses Node SEA (https://nodejs.org/api/single-executable-applications.html) to create an .exe with the intention of converting a Quickbooks report saved as a CSV to invoice PDFs. The program works on my local machine and I bundled it to an .exe (which also works on my local machine) and sent it to the client, where the following error message occurs:
Error Text:
Error: Could not find Chrome (ver. 123.0.6312.58). This can occur if either 1. you did not perform installation before running the script (e.g. 'npx puppeteer browsers install chrome') or 2. your cache path is incorrectly configured (which is: C:\Users\username \ .cache\puppeteer). For (2) check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration
Simplified puppeteer code:
const puppeteer = require('puppeteer');
const generatePDFBuffer = async function (html) {
// Launch a new chrome instance
const browser = await puppeteer.launch({
headless: true
});
// Create a new page
const page = await browser.newPage();
await page.emulateMediaType('print');
// Set your html as the pages content
await page.setContent(html, {
waitUntil: 'domcontentloaded',
});
// Create a pdf buffer
const pdfBuffer = await page.pdf({
format: 'A4',
printBackground: true, // required for basic styling, background colors
preferCSSPageSize: true, // required for maintaining page margins when iterating over a table > 1 page
});
// Close the browser
await browser.close();
return pdfBuffer;
};
I tried adding a .cjs file to the root of my project per the puppeteer configuration dev guide, which seemed like that would be the root cause, but it didn't work: https://pptr.dev/guides/configuration.
Any help in troubleshooting this would be appreciated. You can clone this public repo to recreate the .exe and bug: https://github.com/alexcartaz/CSV-to-PDF.
Upvotes: 0
Views: 131