chromium: [BUG] spawn Unknown system error -8

Environment

  • chromium Version: chromium-min 110.0.1
  • puppeteer / puppeteer-core Version: puppeteer-core 19.6.3
  • Node.js Version: 18.14.1
  • Lambda / GCF Runtime: running locally first

Expected Behavior

I tried to run the code here.

Current Behavior

Error: spawn Unknown system error -8
    at ChildProcess.spawn (node:internal/child_process:413:11)
    at Module.spawn (node:child_process:757:9)
    at BrowserRunner.start (file:///app/node_modules/puppeteer-core/lib/esm/puppeteer/node/BrowserRunner.js:91:34)
    at ChromeLauncher.launch (file:///app/node_modules/puppeteer-core/lib/esm/puppeteer/node/ChromeLauncher.js:68:16)

Steps to Reproduce

See above.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 7
  • Comments: 17 (3 by maintainers)

Commits related to this issue

Most upvoted comments

import chromium from '@sparticuz/chromium-min';
import { executablePath } from 'puppeteer';
import * as puppeteer from 'puppeteer-core';

 browser = await puppeteer.launch(
      process.env.NODE_ENV === 'production'
        ? {
            args: chromium.args,
            defaultViewport: chromium.defaultViewport,
            executablePath: await chromium.executablePath(
              'https://drive.google.com/uc?id=1Sw60gty75maoAr2fsIcu-CDJZ5O8RHrm&export=download',
            ),
            headless: chromium.headless,
            ignoreHTTPSErrors: true,
          }
        : {
            headless: false,
            executablePath: executablePath(),
          },
    );

For local development I did this and bow it’s working.

on M1 you can do a arch -x86_64 zsh

in your terminal prior to running and it should work. You’ll need to have the x86 packages installed prior to. You can do it by running this for example

npm install --arch=x86 --save puppeteer-core@18.0.5 npm install --arch=x86 --save @sparticuz/chromium@106

This happened for me because I was on the new macOS “Apple Silicon” in the terminal Apple will not prompt you to install Rosetta which is required for certain apps to run. Simply running softwareupdate --install-rosetta solved the issue for me.

More information about Rosetta here https://support.apple.com/en-gb/HT211861

@Kal-Toh I’ve managed to make it work… with playwright. I’ve installed playwright-core as a dependency and playwright as a devDependency and now it knows how to spawn the browser. I’ve tried the same solution with puppeteer but I couldn’t make it work.

const browser = await playwright.chromium.launch({
      args: chromium.args,
      executablePath: process.env.AWS_EXECUTION_ENV
        ? await chromium.executablePath(
            '/opt/nodejs/node_modules/@sparticuz/chromium/bin',
          )
        : playwright.chromium.executablePath(),
      headless: true
    })

Yeah, the issue for me was that it wasn’t compatible with my systems architecture, thus wouldn’t work on a local environment. It functions as expected when deployed.

Best thing to do is code>deploy>test>code>deploy>test etc.