我有整个事情在本地工作,但失败,只要它在heroku服务器上。
实现
await pdf.create(pdfTemplate(data)).toStream(async function (err, stream) {
await stream.pipe(fs.createWriteStream(`${req.body.phone}.pdf`));
const params = {
Bucket: "icon-path-bucket",
Body: stream,
Key: req.body.phone,
contentType: "application/pdf"
}
字符串
错误(生产中)
2023-06-17T10:16:06.144530+00:00 app[web.1]: await stream.pipe(fs.createWriteStream(`${req.body.phone}.pdf`));
2023-06-17T10:16:06.144530+00:00 app[web.1]: ^
2023-06-17T10:16:06.144530+00:00 app[web.1]:
2023-06-17T10:16:06.144531+00:00 app[web.1]: TypeError: Cannot read properties of undefined (reading 'pipe')
型
1条答案
按热度按时间wb1gzix01#
html-pdf已经被弃用了,所以我可以在heroku构建包
https://github.com/jontewks/puppeteer-heroku-buildpack
中使用puppeteer
。具体实现如下:字符串
如果没有heroku构建包,即使它在本地工作,它仍然会在服务器上失败。或服务器的正确配置:参见
https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#could-not-find-expected-browser-locally