{"record":{"id":"924cbd0a4cf4d4c3","repo":"GoogleChrome/lighthouse","slug":"usage-0-url","errorCode":null,"errorMessage":"Usage $0: <url>","messagePattern":"Usage \\$0: <url>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/scripts/lantern/debug-url.js","lineNumber":16,"sourceCode":"#!/usr/bin/env node\n/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport path from 'path';\nimport {execFileSync} from 'child_process';\n\nimport constants from './constants.js';\nimport {LH_ROOT} from '../../../shared/root.js';\nimport {readJson} from '../../test/test-utils.js';\n\nconst INPUT_URL = process.argv[2];\nif (!INPUT_URL) throw new Error('Usage $0: <url>');\n\nconst SITE_INDEX_PATH = path.resolve(process.cwd(), constants.SITE_INDEX_WITH_GOLDEN_PATH);\nconst SITE_INDEX_DIR = path.dirname(SITE_INDEX_PATH);\nconst RUN_ONCE_PATH = path.join(LH_ROOT, 'core/scripts/lantern/run-once.js');\n\nconst siteIndex = readJson(SITE_INDEX_PATH);\n// @ts-expect-error - over-aggressive implicit any on site\nconst site = siteIndex.sites.find(site => site.url === INPUT_URL);\nif (!site) throw new Error(`Could not find with site URL ${INPUT_URL}`);\n\nconst trace = path.join(SITE_INDEX_DIR, site.unthrottled.tracePath);\nconst log = path.join(SITE_INDEX_DIR, site.unthrottled.devtoolsLogPath);\nprocess.env.LANTERN_DEBUG = 'true';\nexecFileSync('node', ['--inspect-brk', RUN_ONCE_PATH, trace, log], {stdio: 'inherit'});\n","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/core/scripts/lantern/debug-url.js#L1-L31","documentation":"Usage guard at the top of debug-url.js, a CLI script that launches a debug Lantern run for a single URL. It reads the URL from process.argv[2] and throws immediately if no positional argument was provided. This is a standard argument-validation pattern for standalone Node scripts.","triggerScenarios":"Running `node core/scripts/lantern/debug-url.js` with no arguments, or with arguments that don't reach argv[2] (e.g., flags parsed before the URL). process.argv[2] is undefined.","commonSituations":"Forgetting the URL argument. Copy-paste error in a command. Running the script through a wrapper that doesn't forward positional arguments.","solutions":["Provide a URL as the first positional argument: `node core/scripts/lantern/debug-url.js https://example.com`","Ensure the URL must exactly match a site.url in the site index JSON"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const INPUT_URL = process.argv[2];\nif (!INPUT_URL) {\n  console.error('Usage: node debug-url.js <url>');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide the URL as the first positional argument","Use a shell wrapper or npm script that validates arguments before invoking"],"tags":["cli","usage","lantern","arguments"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}