{"record":{"id":"5a59c7f58c6e9cfc","repo":"vercel/next.js","slug":"failed-to-install-packagetoinstall-please-in","errorCode":null,"errorMessage":"Failed to install \"${packageToInstall}\". Please install it manually.","messagePattern":"Failed to install \"(.+?)\"\\. Please install it manually\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next-codemod/lib/handle-package.ts","lineNumber":172,"sourceCode":"  } = options\n\n  if (!packageManager) throw new Error('Failed to find package manager')\n\n  const addCmd = ADD_CMD_FLAG[packageManager]\n  const devDepFlag = dev ? DEV_DEP_FLAG[packageManager] : undefined\n\n  const installFlags = [addCmd]\n  if (devDepFlag) {\n    installFlags.push(devDepFlag)\n  }\n  try {\n    execa.sync(packageManager, [...installFlags, ...packageToInstall], {\n      // Keeping stderr since it'll likely be relevant later when it fails.\n      stdio: silent ? ['ignore', 'ignore', 'inherit'] : 'inherit',\n      shell: true,\n    })\n  } catch (error) {\n    throw new Error(\n      `Failed to install \"${packageToInstall}\". Please install it manually.`,\n      { cause: error }\n    )\n  }\n}\n\nexport function runInstallation(\n  packageManager: PackageManager,\n  options: { cwd: string }\n) {\n  try {\n    execa.sync(packageManager, ['install'], {\n      cwd: options.cwd,\n      env: {\n        ...process.env,\n        // In case NODE_ENV=production is set, we still want dev dependencies to\n        // be installed. Otherwise we won't be able to check for peer dependencies.\n        // --production=false is not implemented by every package manager.","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next-codemod/lib/handle-package.ts#L154-L190","documentation":"Thrown by `installPackages` in next-codemod when `execa.sync` running `<pkgManager> <install|add> <packages...>` exits non-zero. The original error is preserved as `cause`. The codemod gives up and asks you to install the package manually.","triggerScenarios":"Any next-codemod that installs new packages (e.g., adding eslint dependencies during the next-lint-to-eslint-cli migration) when the package manager add/install subprocess fails.","commonSituations":"Network or registry connectivity issues; package version conflicts or unresolvable peer deps; disk space or permission errors; running behind a corporate proxy that blocks the registry; corrupted package manager cache.","solutions":["Run the install command manually to see the full error: `npm install <package>` (or `pnpm add`, `yarn add`, `bun add`).","Clear the package manager cache (`npm cache clean --force`, `pnpm store prune`) and retry.","Check for peer dependency conflicts and resolve them before re-running the codemod.","Verify network/proxy connectivity to the npm registry."],"exampleFix":"// The codemod runs this internally and fails:\ninstallPackages(['eslint', '@eslint/js'])\n\n// Run the equivalent manually:\n// pnpm add eslint @eslint/js","handlingStrategy":"try-catch","validationCode":"// Verify network/registry connectivity before installing\nimport { execSync } from 'child_process'\nfunction canReachRegistry(): boolean {\n  try { execSync('npm ping', { stdio: 'ignore' }); return true } catch { return false }\n}","typeGuard":null,"tryCatchPattern":"try {\n  installPackages(['next'], { packageManager: 'npm' })\n} catch (e) {\n  console.error(e.message) // Failed to install ...\n  // e.cause has the execa error with exit code and stderr\n  process.exit(1)\n}","preventionTips":["Verify registry connectivity before running codemods that install packages.","Resolve peer dependency conflicts in package.json beforehand.","Ensure sufficient disk space and write permissions on node_modules."],"tags":["codemod","package-manager","dependency-management","subprocess"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}