React-snap fails on deployment with missing chrome dependencies

I recently added react-snap to prerender dynamic content in my React app for SEO and embeds. This, however, breaks the build. It fails with:

Error: Failed to launch chrome!
/vercel/path0/web/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

I assume this means puppeteer isn’t fully configured, but I don’t know how to install the dependencies it needs otherwise. The updates on this similar issue hint that Vercel now supports running puppeteer at build time, but that isn’t what I’m seeing here.

I’ve also tried running ldd chrome | grep not in package.json "postbuild" according to the puppeteer troubleshooting docs to get the dependencies and install them before react-snap, but the build env can’t find chrome, so it fails on ldd chrome.

Am I missing a configuration somewhere that will properly resolve this build issue?

Edit: I’ve also found this stack overflow thread that mentions a number of possible options. I’m still running through them, but currently the node version is a nonstarter, I can’t even configure the app to use node 14.x and using anything higher seems to fail anyways.

Update: I’ve resolved to using prerender.io instead for a CDN-based caching solution, this works wonders for my use case. react-snap was locally having trouble picking up dynamically generated queries anyways. Would still enjoy a solution here in case anyone else runs into this wall.

Hey, Solis!

I’m marking your answer as a solution for now. I’ll leave this open for anyone else that may have other ideas. :pray:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.