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