heroku 错误:编译的 slug 大小:对于 Puppeteer 来说太大

发布于 2025-01-10 18:30:45 字数 269 浏览 2 评论 0原文

我的应用程序正在本地主机上运行,​​但是当我在heroku上部署时,puppeteer应用程序需要此模块 https:// github.com/jontewks/puppeteer-heroku-buildpack。 puppeteer node_module 大小约为 300mb,该模块大小为 200。总大小为 539mb。请提出一个好的解决方案

My app is working on localhost but when i deploy on heroku this module is required for puppeteer app https://github.com/jontewks/puppeteer-heroku-buildpack. puppeteer node_module size is around 300mb and this module size is 200.Total size is 539mb. Please suggest a good solution

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别忘他 2025-01-17 18:30:45

面临同样的问题。

以下步骤将我的 slug 大小从大约 530MB 减少到大约 250MB。


1 — 更新构建包

添加 heroku/google-chrome 构建包。将其放在 heroku/nodejs 构建包之上。这里不再需要 jontewks/puppeteer-heroku-buildpack 了。

buildpacks


2 — 添加新的 ENV 变量

添加PUPPETEER_EXECUTABLE_PATH。在本地环境中,将此环境变量设置为 \path\to\chrome.exe。在 Heroku 中,将此环境变量设置为 google-chrome

还要添加PUPPETEER_SKIP_DOWNLOAD,并将其设置为true。这告诉 Puppeteer 跳过下载 Chromium。

环境变量


3 — 更新 Puppeteer 配置

Puppeteer 的 启动选项包括executablePath。将其设置为PUPPETEER_EXECUTABLE_PATH

puppeteer config


4 — 部署,大功告成!

将提交推送到 Heroku 以触发新的部署。希望到那时您的 slug 大小会减少,并且您的 Heroku 应用程序应该能够成功部署。

slug 大小

Faced the same issue.

The following steps reduced my slug size from around 530MB to around 250MB.


1 — Update buildpacks

Add the heroku/google-chrome buildpack. Place it above the heroku/nodejs buildpack. The jontewks/puppeteer-heroku-buildpack is not required here anymore.

buildpacks


2 — Add new ENV variables

Add PUPPETEER_EXECUTABLE_PATH. In your local environment, set this env variable as \path\to\chrome.exe. In Heroku, set this env variable as google-chrome.

Also add PUPPETEER_SKIP_DOWNLOAD, and set it to true. This tells Puppeteer to skip downloading Chromium.

env variables


3 — Update Puppeteer config

Puppeteer's launch options includes executablePath. Set this to PUPPETEER_EXECUTABLE_PATH.

puppeteer config


4 — Deploy, you're done!

Push commit to Heroku to trigger new deployment. Hopefully, your slug size will have reduced by then, and your Heroku app should be able to deploy successfully.

slug size

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文