简体   繁体   English

Heroku:puppeteer chrome:加载共享库时出错:libX11-xcb.so.1

[英]Heroku: puppeteer chrome: error while loading shared libraries: libX11-xcb.so.1

I get following error when deploying app with react-snap to Heroku.使用react-snap将应用程序部署到 Heroku 时出现以下错误。

puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory

I applied all the changes, set all the buildpacks.我应用了所有更改,设置了所有构建包。

I even could react the the first deploy without "postbuild": "react-snap" line, it workes.我什至可以在没有"postbuild": "react-snap"行,它可以工作。

But then adding lines here, will fail again.但是,然后在这里添加行,将再次失败。 What now?现在怎么办?

"reactSnap": {
    "cacheAjaxRequests": true,
    "inlineCss": true,
    "http2PushManifest": true,
    "puppeteerArgs": ["--no-sandbox", "--disable-setuid-sandbox"]
  }
"postbuild": "react-snap"

I struggled with this issue for 4 hours.我在这个问题上挣扎了 4 个小时。 Googled a lot of solutions but no one worked for me.谷歌搜索了很多解决方案,但没有一个适合我。 And finally I've got it,!!最后我明白了,!! (Actually, it is now at this very moment) (其实就是此时此刻)

Heroku log: Heroku 日志:

 > individual-claims@0.1.0 postbuild /tmp/build_3cc3bffa_ > react-snap ✅ crawled 1 out of 1 (/)

Done.完毕。 I am happy.我很开心。

Solution:解决方案:

  1. Go to Heroku Settings -> Buildpacks -> Add buildpack Go 到 Heroku 设置 -> 构建包 -> 添加构建包
  2. Add: https://github.com/jontewks/puppeteer-heroku-buildpack.git地址: https://github.com/jontewks/puppeteer-heroku-buildpack.git

IMPORTANT !!!重要的 !!! Make sure this is the first one.确保这是第一个。 That's the common fault.这就是通病。 When making React on Heroku you already (I suppose) have https://github.com/mars/create-react-app-buildpack.git But react-buildpack should be the second one.在 Heroku 上进行 React 时,您已经(我想)拥有https://github.com/mars/create-react-app-buildpack.git但 react-pack 应该是第二个Nobody says it.没人说。

  1. Redeploy and have fun.重新部署并享受乐趣。

Note: After a lot of struggling I've made some changes to my application (I don't think this is really important, however)注意:经过一番挣扎后,我对我的应用程序进行了一些更改(但是我认为这并不重要)

  1. in package.json在 package.json
     "engines": {
          "node": ">=14.12.0",  // Just to make sure I have the latest and the greatest 
          "npm": ">=6.14.8"
        },
  
   "devDependencies": {
        ...
       "prettier": "^2.1.2",   // Just to make sure I have the latest and the greatest 
        ...
   }
  1. Heroku stack: heroku-18. Heroku 堆栈:heroku-18。 It's the default and you have it unless your app is old.这是默认设置,除非您的应用程序较旧,否则您拥有它。

  2. I don't have these lines:我没有这些行:

"cacheAjaxRequests": true,
"inlineCss": true,
"http2PushManifest": true,

I've heard that "inlineCss": true, may cause a problem我听说“inlineCss”:是的,可能会导致问题

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

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