diff --git a/scripts/pagespeed-sitemap.ts b/scripts/pagespeed-sitemap.ts index 8465061c..094db066 100644 --- a/scripts/pagespeed-sitemap.ts +++ b/scripts/pagespeed-sitemap.ts @@ -95,12 +95,41 @@ async function main() { console.log(`✅ Detected Puppeteer Chrome at: ${chromePath}`); } } catch (e: any) { - console.warn(`⚠️ Could not detect Puppeteer Chrome path automatically: ${e.message}`); + console.warn(`⚠️ Could not detect Puppeteer Chrome path via command: ${e.message}`); + } + + // Fallback to known paths if still not found + if (!chromePath) { + const fallbacks = [ + '/root/.cache/puppeteer/chrome/linux-145.0.7632.77/chrome-linux64/chrome', + '/home/runner/.cache/puppeteer/chrome/linux-145.0.7632.77/chrome-linux64/chrome', + path.join( + process.cwd(), + 'node_modules', + '.puppeteer', + 'chrome', + 'linux-145.0.7632.77', + 'chrome-linux64', + 'chrome', + ), + ]; + + for (const fallback of fallbacks) { + if (fs.existsSync(fallback)) { + chromePath = fallback; + console.log(`✅ Found Puppeteer Chrome at fallback: ${chromePath}`); + break; + } + } } } else { console.log(`ℹ️ Using existing Chrome path: ${chromePath}`); } + if (!chromePath) { + console.warn('❌ CHROME_PATH is still undefined. Lighthouse might fail.'); + } + const chromePathArg = chromePath ? `--collect.chromePath="${chromePath}"` : ''; // Clean up old reports