{"record":{"id":"eea071dd9dd250ae","repo":"vercel/next.js","slug":"failed-to-get-registry-from-pkgmanager","errorCode":null,"errorMessage":"Failed to get registry from \"${pkgManager}\".","messagePattern":"Failed to get registry from \"(.+?)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/lib/helpers/get-registry.ts","lineNumber":37,"sourceCode":"\n  try {\n    const output = execSync(\n      `${pkgManager} config get registry ${resolvedFlags}`,\n      {\n        env: {\n          ...process.env,\n          NODE_OPTIONS: getFormattedNodeOptionsWithoutInspect(),\n        },\n      }\n    )\n      .toString()\n      .trim()\n\n    if (output.startsWith('http')) {\n      registry = output.endsWith('/') ? output : `${output}/`\n    }\n  } catch (err) {\n    throw new Error(`Failed to get registry from \"${pkgManager}\".`, {\n      cause: err,\n    })\n  }\n\n  return registry\n}\n","sourceCodeStart":19,"sourceCodeEnd":44,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/lib/helpers/get-registry.ts#L19-L44","documentation":"Thrown by getRegistry() when execSync(`<pkgManager> config get registry ...`) fails. The function needs the registry URL to download SWC binaries; if the package-manager subprocess errors (binary missing, command rejected, NODE_OPTIONS rejected), it re-throws wrapping the original error as `cause`.","triggerScenarios":"getRegistry() is called during SWC binary download. It runs `npm config get registry --no-workspaces` (or yarn/pnpm equivalent). If the pkg manager binary isn't on PATH, the command exits non-zero, or NODE_OPTIONS contains a disallowed flag that Node rejects, execSync throws and getRegistry re-wraps it.","commonSituations":"Container/CI images without npm/yarn/pnpm installed; a corrupted .npmrc that breaks `npm config`; NODE_OPTIONS containing --inspect which getFormattedNodeOptionsWithoutInspect strips but a leftover invalid token still breaks the child; or a custom package manager shim that exits non-zero. Often co-occurs with [107]/[108] since registry resolution precedes the download.","solutions":["Ensure the detected package manager binary is installed and on PATH: `which npm` (or yarn/pnpm).","Inspect err.cause from the thrown error for the real subprocess exit message and fix accordingly.","Sanitize NODE_OPTIONS (remove --inspect and other disallowed flags) before running the build.","Set the registry explicitly via NEXT_SWC_PATH or a pre-installed binary to bypass getRegistry entirely."],"exampleFix":"# before: npm missing in container\npnpm build  # Failed to get registry from \"npm\"\n# after: install npm or use pnpm consistently\napt-get install -y npm\n# or avoid the path: pre-install the swc binary\npnpm add @next/swc-linux-x64-gnu","handlingStrategy":"validation","validationCode":"import { execSync } from 'child_process'\nfunction assertRegistryResolvable(pm: string) {\n  try {\n    execSync(`${pm} config get registry`, { stdio: 'pipe' })\n  } catch (e) {\n    throw new Error(`Package manager '${pm}' unavailable or misconfigured`, { cause: e })\n  }\n}","typeGuard":"function pkgManagerOnPath(pm: string): boolean {\n  try { execSync(`${pm} --version`, { stdio: 'pipe' }); return true }\n  catch { return false }\n}","tryCatchPattern":"try {\n  return getRegistry()\n} catch (e) {\n  if (/Failed to get registry/.test(e.message)) {\n    console.error('Registry lookup failed — check package manager install and NODE_OPTIONS')\n  }\n  // fall back to default registry or pre-installed binary\n  return 'https://registry.npmjs.org/'\n}","preventionTips":["Ensure the detected package manager is installed in all CI/containers.","Sanitize NODE_OPTIONS (no --inspect) before building.","Pre-install SWC binaries to bypass getRegistry entirely.","Validate .npmrc does not break `npm config get registry`."],"tags":["network","package-manager","swc","build","environment"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}