{"record":{"id":"3c20a8e84234843a","repo":"denoland/deno","slug":"could-not-resolve-the-native-typescript-compiler","errorCode":null,"errorMessage":"could not resolve the native TypeScript compiler; download {} manually and copy its lib/ next to {}","messagePattern":"could not resolve the native TypeScript compiler; download (.+?) manually and copy its lib/ next to (.+?)","errorType":"exception","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"cli/tsc/native.rs","lineNumber":129,"sourceCode":"\n  if tsc_path.exists() {\n    return Ok(tsc_path);\n  }\n\n  let pkg_name = format!(\"@typescript/typescript-{}\", target);\n  let nv = PackageNv::from_str(&format!(\"{}@{}\", pkg_name, TYPESCRIPT_VERSION))\n    .unwrap();\n  let mut info = api.package_info(&pkg_name).await?;\n  let version_info = match info.version_info(&nv, &workspace_link_packages.0) {\n    Ok(version_info) => version_info,\n    Err(_) => {\n      api.mark_force_reload();\n      info = api.package_info(&pkg_name).await?;\n      info.version_info(&nv, &workspace_link_packages.0)?\n    }\n  };\n  let Some(dist) = &version_info.dist else {\n    anyhow::bail!(\n      \"could not resolve the native TypeScript compiler; download {} manually and copy its lib/ next to {}\",\n      nv,\n      tsc_path.display()\n    );\n  };\n\n  let registry_url = npmrc.get_registry_url(&nv.name);\n  let package_folder =\n    npm_cache.package_folder_for_nv_and_url(&nv, registry_url);\n  let existed = package_folder.exists();\n  if !existed {\n    // `ensure_package` downloads the tarball and verifies it against the\n    // registry `dist` integrity/shasum before extracting (the standard npm\n    // pipeline), so the materialized compiler is checksum-validated at install.\n    tarball_cache\n      .ensure_package(&nv, dist)\n      .await\n      .with_context(|| {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tsc/native.rs#L111-L147","documentation":"`ensure_native_tsc` resolves `@typescript/typescript-<platform>@<TYPESCRIPT_VERSION>` through the configured npm registry and needs the version's `dist` block (tarball URL + integrity hash) to download the compiler. If `version_info.dist` is None — even after one forced registry reload (cli/tsc/native.rs:123) — Deno cannot build a download and bails, telling you to fetch the package manually and place its `lib/` next to the expected tsc path.","triggerScenarios":"First `deno check` / type-checking run where the registry from .npmrc (`registry=`, scoped registries) returns metadata for the exact package@version but without a `dist` field; or corrupted/stale cached registry metadata under DENO_DIR that still lacks dist after the internal reload retry.","commonSituations":"Corporate Artifactory/Verdaccio/npm-proxy mirrors that strip or incompletely cache `dist`; air-gapped registries; a project or user .npmrc pointing at a private registry that has the package metadata but not the tarball reference; interrupted earlier metadata fetches leaving a bad cache.","solutions":["Follow the message: `npm pack @typescript/typescript-<platform>@<version>`, extract the tarball, and copy its `lib/` to the path printed in the error (e.g. $DENO_DIR/tsc/<version>/<platform>/lib/).","Or set `DENO_TSC_BIN` to any existing tsc binary — Deno skips the registry entirely.","Fix the registry/mirror so it returns full metadata including dist; verify with `npm view @typescript/typescript-<platform>@<version> dist.tarball`.","Clear the cached npm metadata (`rm -rf \"${DENO_DIR:-$HOME/.cache/deno}/npm\"`) and retry so the forced reload fetches complete info."],"exampleFix":"# before: deno check fails:\n# could not resolve the native TypeScript compiler; download @typescript/typescript-linux-x64@<version> manually ...\nnpm pack @typescript/typescript-linux-x64\ntar -xzf typescript-typescript-linux-x64-*.tgz\nmkdir -p \"${DENO_DIR:-$HOME/.cache/deno}/tsc/<version>/linux-x64\"\ncp -r package/lib \"${DENO_DIR:-$HOME/.cache/deno}/tsc/<version>/linux-x64/\"\ndeno check main.ts","handlingStrategy":"fallback","validationCode":"# verify the registry serves full metadata (dist) for the platform package\nnpm view @typescript/typescript-<platform>@<version> dist.tarball\n# empty output => deno's auto-download will fail with this error","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify mirrors expose dist metadata (`npm view <pkg> dist.tarball`) before pointing .npmrc at them.","Pin DENO_TSC_BIN in CI to a pre-warmed compiler so type checking never depends on registry metadata.","Bake the downloaded compiler ($DENO_DIR/tsc/...) into container images to avoid registry dependence at runtime."],"tags":["typescript","npm-registry","native-tsc","private-registry","offline"],"backgroundTag":"npm-package-resolution-failed","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}