aquí está todo el código que estoy usando para intentar descargar un archivo PDF que se creó anteriormente:
import puppeteer, { PDFOptions } from 'puppeteer'; interface Request { pageContent: string; pdfOptions?: PDFOptions; } class GeneratePDFFileService { async execute({ pageContent, pdfOptions }: Request): Promise<Buffer> { const browser = await puppeteer.launch ({ headless: true, args:['--no-sandbox'] }); const page = await browser.newPage(); await page.setContent(pageContent); const pdfFileOptions = pdfOptions || { printBackground: true, format: 'a4', margin: { top: '2cm', left: '2cm', bottom: '2cm', right: '2cm', }, preferCSSPageSize: true, }; const pdf = await page.pdf(pdfFileOptions); await browser.close(); return pdf; } } export { GeneratePDFFileService };
Aquí está el error:
application | Error: Failed to launch the browser process! spawn /usr/bin/chromium-browser ENOENT application | application | application | TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md application | application | at onClose (/usr/app/node_modules/puppeteer/src/node/BrowserRunner.ts:261:9) application | at ChildProcess.<anonymous> (/usr/app/node_modules/puppeteer/src/node/BrowserRunner.ts:250:9) application | at ChildProcess.emit (events.js:400:28) application | at Process.ChildProcess._handle.onexit (internal/child_process.js:280:12) application | at onErrorNT (internal/child_process.js:469:16) application | at processTicksAndRejections (internal/process/task_queues.js:82:21)
Versión titiritero:
"puppeteer": "^13.1.3",
Probé algunos consejos en Troubleshooting.md , pero no tengo idea si lo estoy haciendo bien.