Puppeteer-core runs locally but fails on Vercel deployment

Below is an alternative snippet. Vercel deployment crashes due to missing libnss3.so.

import altBrowser from 'alt-chrome';
export async function fetchData(username) { return await altBrowser.run({ headless: true, args: ['--no-sandbox'] }); }

hey, i’ve faced similar issues. try adding your missing libnss3 dependency via a custom buildpack on vercel. might help so your altBrowser can run properly. good luck!

The error related to libnss3.so typically indicates that the deployed function is missing system dependencies that are present locally. I resolved similar issues by switching to a Docker-based deployment, ensuring that the container image included the necessary libraries. This approach allows for more control over the environment, rather than relying solely on Vercel’s default settings. A few adjustments in the Dockerfile did the trick. If Docker is not an option, modifying the configuration to install the missing libraries during the build phase may also prove effective.

I encountered a similar issue while deploying puppeteer-based applications on Vercel. In my experience, the root cause lies in the incomplete environment that Vercel provides compared to your local machine. I resolved the issue by modifying the Vercel build script to include the installation of all necessary dependencies. Although it required some tinkering with the deployment script, ensuring that the missing libraries were installed before launching the browser process made a significant difference. Experimenting with environment variables and custom configuration in the build phase also helped in streamlining the solution.

hey, i solved it by adding an apt-get install step for libnss3 in my build script. vercel then loaded the lib, and everything worked. hope this helps!