简体   繁体   English

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

[英]heroku Error: compiled slug size: is too large with Puppeteer

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 .我的应用程序在本地主机上工作,但是当我在 heroku 上部署时,这个模块是 puppeteer 应用程序https://github.com/jontewks/puppeteer-heroku-buildpack所必需的。 puppeteer node_module size is around 300mb and this module size is 200.Total size is 539mb. puppeteer node_module 大小约为 300mb,此模块大小为 200。总大小为 539mb。 Please suggest a good solution请提出一个好的解决方案

Faced the same issue.面临同样的问题。

The following steps reduced my slug size from around 530MB to around 250MB.以下步骤将我的 slug 大小从大约 530MB 减少到大约 250MB。


1 — Update buildpacks 1 — 更新构建包

Add the heroku/google-chrome buildpack.添加heroku/google-chrome buildpack。 Place it above the heroku/nodejs buildpack.将它放在heroku/nodejs buildpack 之上。 The jontewks/puppeteer-heroku-buildpack is not required here anymore.这里不再需要jontewks/puppeteer-heroku-buildpack

构建包


2 — Add new ENV variables 2 — 添加新的 ENV 变量

Add PUPPETEER_EXECUTABLE_PATH .添加PUPPETEER_EXECUTABLE_PATH In your local environment, set this env variable as \path\to\chrome.exe .在您的本地环境中,将此环境变量设置为\path\to\chrome.exe In Heroku, set this env variable as google-chrome .在 Heroku 中,将此环境变量设置为google-chrome

Also add PUPPETEER_SKIP_DOWNLOAD , and set it to true .同时添加PUPPETEER_SKIP_DOWNLOAD ,并将其设置为true This tells Puppeteer to skip downloading Chromium.这告诉 Puppeteer 跳过下载 Chromium。

环境变量


3 — Update Puppeteer config 3 — 更新 Puppeteer 配置

Puppeteer's launch options includes executablePath . Puppeteer 的启动选项包括executablePath Set this to PUPPETEER_EXECUTABLE_PATH .将其设置为PUPPETEER_EXECUTABLE_PATH

傀儡配置


4 — Deploy, you're done! 4 — 部署,大功告成!

Push commit to Heroku to trigger new deployment.将提交推送到 Heroku 以触发新部署。 Hopefully, your slug size will have reduced by then, and your Heroku app should be able to deploy successfully.希望到那时您的 slug 大小会减小,并且您的 Heroku 应用程序应该能够成功部署。

弹头尺寸

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM