From 782aaf63a600a571ba7a0f6d4f105f7f58895315 Mon Sep 17 00:00:00 2001 From: DeNNiiInc Date: Sat, 27 Dec 2025 23:10:02 +1100 Subject: [PATCH] Fix ERR_REQUIRE_ESM: Use dynamic import for Chrome Launcher --- lib/runner.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/runner.js b/lib/runner.js index 4d525b4..388fceb 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -1,5 +1,4 @@ -// lighthouse is ESM only, imported dynamically -const chromeLauncher = require('chrome-launcher'); +// lighthouse & chrome-launcher are ESM only/compatible, imported dynamically const fs = require('fs'); const path = require('path'); const { v4: uuidv4 } = require('uuid'); @@ -11,8 +10,9 @@ const { v4: uuidv4 } = require('uuid'); * @returns {Promise} - Test results */ async function runTest(url, options = {}) { - // Dynamically import Lighthouse (ESM) + // Dynamically import Lighthouse & Chrome Launcher (ESM) const { default: lighthouse } = await import('lighthouse'); + const { default: chromeLauncher } = await import('chrome-launcher'); const isMobile = options.isMobile ?? true; // Default to mobile const reportDir = path.join(__dirname, '..', 'reports');