Fixing Browser Error

Failed to launch the browser process

Fixing Browser Error

Install Node.js

curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

This command installs Node.js (18.x) on your system.

Setting the Executable Path for Puppeteer

import type { NextApiRequest, NextApiResponse } from 'next';
const browser = await puppeteer.launch({
  executablePath: '/usr/bin/chromium-browser' // Chromium exec path

This code sets the executablePath option in Puppeteer to the path of the Chromium executable. The /usr/bin/chromium-browser specifies the location of the Chromium browser executable file on the system.

Update and Upgrade Chromium Browser

sudo apt-get update
sudo apt-get upgrade chromium-browser

These commands update and upgrade the Chromium browser on your system.