Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
Issue running puppeteer in github actions

Everything works fine locally, but when I try to run my script using puppeteer in github action, I get this:

file:///dist/index.js:49412
    const puppeteerRootDirectory = pkg_dir_1.default.sync(__dirname);
                                                          ^

ReferenceError: __dirname is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/dist/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

I've tried defining the __dirname before importing puppeteer but haven't had any luck. e.g.

import {dirname} from "path";
globalThis.__dirname = dirname(import.meta.url);
import puppeteer from "puppeteer";

EDIT:

This appears to be an issue with compiling via ncc. I can repro locally when I run ncc run [my script]. I've looked into how to define __dirname for modules but am still running into issues. I tried something like this and adding it at the top of my script before my import statement but it doesn't make a difference. Is there anywhere I can add it that it would be recognized by puppeteer?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda