heroku 错误:编译的 slug 大小:对于 Puppeteer 来说太大
我的应用程序正在本地主机上运行,但是当我在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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
面临同样的问题。
以下步骤将我的 slug 大小从大约 530MB 减少到大约 250MB。
1 — 更新构建包
添加
heroku/google-chrome
构建包。将其放在heroku/nodejs
构建包之上。这里不再需要 jontewks/puppeteer-heroku-buildpack 了。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。4 — 部署,大功告成!
将提交推送到 Heroku 以触发新的部署。希望到那时您的 slug 大小会减少,并且您的 Heroku 应用程序应该能够成功部署。
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 theheroku/nodejs
buildpack. Thejontewks/puppeteer-heroku-buildpack
is not required here anymore.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 asgoogle-chrome
.Also add PUPPETEER_SKIP_DOWNLOAD, and set it to
true
. This tells Puppeteer to skip downloading Chromium.3 — Update Puppeteer config
Puppeteer's launch options includes
executablePath
. Set this to PUPPETEER_EXECUTABLE_PATH.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.