gpt4 book ai didi

node.js - 错误: Failed to launch the browser process puppeteer

转载 作者:行者123 更新时间:2023-12-03 12:09:42 27 4
gpt4 key购买 nike

检查失败
crashForExceptionInNonABIComplianceCodeRange
函数下方的代码是创建PDF文件

   (async function() {

try {

const browser = await puppeteer.launch();
const page = await browser.newPage();

await page.setContent(pdfOutput);
await page.emulateMedia("screen");
await page.pdf({
path: "routes/planiton/pdf/mypdf.pdf",
format: "A4",
printBackground: true
});

console.log('done');
await browser.close();
//process.exit();

} catch (e) {
console.log("Our Error", e)
}
})();

最佳答案

我遇到了同样的问题,我尝试了Puppeteer guide列出的所有内容,但没有一个对我有用。
对我有用的是手动下载chrome sudo apt-get install chromium-browser
然后,告诉Puppeteer Chrome 位于何处:

const browser = await puppeteer.launch({
executablePath: '/usr/bin/chromium-browser'
})
希望这会帮助某人:)

关于node.js - 错误: Failed to launch the browser process puppeteer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59979188/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com