{"record":{"id":"cff6ef233bde5bd1","repo":"vercel/next.js","slug":"failed-to-run-command-to-migrate-the-legacy-e","errorCode":null,"errorMessage":"Failed to run \"${command}\" to migrate the legacy ESLint config \"${eslintConfigFilename}\".\nPlease try the migration to Flat config manually.\nLearn more: https://eslint.org/docs/latest/use/configure/migration-guide","messagePattern":"Failed to run \"(.+?)\" to migrate the legacy ESLint config \"(.+?)\"\\.\nPlease try the migration to Flat config manually\\.\nLearn more: https://eslint\\.org/docs/latest/use/configure/migration-guide","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next-codemod/transforms/next-lint-to-eslint-cli.ts","lineNumber":1121,"sourceCode":"        execSync(command, {\n          cwd: projectRoot,\n          stdio: 'pipe',\n        })\n\n        // The migration tool creates eslint.config.mjs by default\n        const outputPath = path.join(projectRoot, 'eslint.config.mjs')\n        if (!existsSync(outputPath)) {\n          throw new Error(\n            `Failed to find the expected output file \"${outputPath}\" generated by the migration tool.`\n          )\n        }\n\n        // Use generated config will have FlatCompat, so continue to apply\n        // the next steps to it.\n        eslintConfigPath = outputPath\n        eslintConfigFilename = path.basename(eslintConfigPath)\n      } catch (cause) {\n        throw new Error(\n          `Failed to run \"${command}\" to migrate the legacy ESLint config \"${eslintConfigFilename}\".\\n` +\n            `Please try the migration to Flat config manually.\\n` +\n            `Learn more: https://eslint.org/docs/latest/use/configure/migration-guide`,\n          { cause }\n        )\n      }\n    }\n\n    console.log(`   Found existing ESLint Flat config: ${eslintConfigFilename}`)\n\n    // First try to replace FlatCompat usage if present\n    replaceFlatCompatInConfig(eslintConfigPath)\n\n    // Always try to update flat config with Next.js configurations\n    // regardless of whether FlatCompat was found\n    const updated = updateExistingFlatConfig(eslintConfigPath, isTypeScript)\n\n    if (!updated) {","sourceCodeStart":1103,"sourceCodeEnd":1139,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next-codemod/transforms/next-lint-to-eslint-cli.ts#L1103-L1139","documentation":"Thrown by the next-lint-to-eslint-cli codemod when the `npx @eslint/migrate-config <path>` command itself fails (execSync throws). The codemod wraps the failure with guidance to attempt the flat config migration manually and links to the ESLint migration guide. The original error is attached as `cause`.","triggerScenarios":"Running the next-lint-to-eslint-cli codemod with an existing legacy ESLint config; the spawned `npx @eslint/migrate-config` command exits non-zero — network failure fetching the package, the tool crashing on an unsupported config format, or npx itself failing.","commonSituations":"No internet access to fetch @eslint/migrate-config via npx; the legacy ESLint config uses an unsupported format or syntax the migration tool can't parse; an incompatible @eslint/migrate-config version; corrupted npx cache.","solutions":["Run `npx @eslint/migrate-config <your-config-file>` manually to see the actual error.","Install @eslint/migrate-config globally or locally and run it directly instead of via npx.","If offline, download the tool or migrate the config by hand following https://eslint.org/docs/latest/use/configure/migration-guide.","Clear npx cache (`npx clear-npx-cache`) and retry."],"exampleFix":"// The codemod runs:\n// npx @eslint/migrate-config .eslintrc.json\n// If it fails, do it manually:\n// npm install -g @eslint/migrate-config\n// eslint-migrate-config .eslintrc.json","handlingStrategy":"try-catch","validationCode":"import { execSync } from 'child_process'\n// Pre-check that @eslint/migrate-config is available\nfunction canRunMigration(): boolean {\n  try { execSync('npx @eslint/migrate-config --help', { stdio: 'ignore' }); return true } catch { return false }\n}","typeGuard":null,"tryCatchPattern":"try {\n  execSync(`npx @eslint/migrate-config ${configPath}`, { cwd: projectRoot, stdio: 'pipe' })\n} catch (e) {\n  // Fall back to manual migration\n  console.error('Automatic ESLint config migration failed. Migrate manually.')\n}","preventionTips":["Ensure internet access is available for npx to fetch @eslint/migrate-config.","Validate the legacy ESLint config is syntactically correct before running the codemod.","Pre-install @eslint/migrate-config locally to avoid npx network failures."],"tags":["codemod","eslint","lint","migration","subprocess"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}