0

I'm trying to deploy a node project that uses puppeteer to a Railway server. It works fine on my local windows environment but not on Railway's linux enviroment. Both enviroments are using Node 18.x.

/app/indeed-job-scraper/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:241
reject(new Error([
^
Error: Failed to launch the browser process!
/app/indeed-job-scraper/node_modules/puppeteer/.local-chromium/linux-982053/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/app/indeed-job-scraper/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:241:20)
at Interface.<anonymous> (/app/indeed-job-scraper/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:231:68)
at Interface.emit (node:events:525:35)
at Interface.close (node:readline:590:8)
at Socket.onend (node:readline:280:10)
at Socket.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1358:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)

This is how I import & launch puppeteer.

let puppeteer     = require('puppeteer-extra');
let StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());

let browser = puppeteer.launch({ headless: true });

Tried adding args: ['--no-sandbox'] & tried downgrading the Node version to 14.x.

The most similar question I've found says to check if the module folder contains all the linux dependencies & manually install them. But not sure how to do that on Railway, maybe use the CLI?

I'd appreciate any ideas on how to figure this out!

Similar question for Vercel: /tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory Vercel

Luke V
  • 3
  • 3

1 Answers1

0

Figured it out. The issue seemed to be that it wasn't installing all the dependencies because they were in a subfolder of the root.

Once I moved all the files & modules to the root, railway recognized the required dependencies.

However, I did have to add other args to puppeteer to prevent more errors.

let { executablePath } = require('puppeteer');
let puppeteer     = require('puppeteer-extra');
//...  
let browser = puppeteer.launch({ headless: true, executablePath: executablePath(), args: ['--no-sandbox'] });
Luke V
  • 3
  • 3