Skip to content

fix(npm): resolve linked packages not published to npm registry#33021

Merged
bartlomieju merged 1 commit intomainfrom
fix/link-npm-package-not-on-registry
Mar 30, 2026
Merged

fix(npm): resolve linked packages not published to npm registry#33021
bartlomieju merged 1 commit intomainfrom
fix/link-npm-package-not-on-registry

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

Summary

  • Fixes the case where "links" in deno.json references a local npm package that has not been published to the npm registry
  • Added package_info_or_link_fallback() helper that falls back to creating a synthetic NpmPackageInfo from link package data when the registry returns PackageNotExists
  • Applied this fallback at all api.package_info() call sites in the npm resolution code (snapshot.rs and graph.rs)

The link package data was already being properly parsed and stored, but the resolution code always fetched from the npm registry first. For unpublished packages, this failed before link packages were ever consulted.

Closes #33010

Test plan

  • Added 2 unit tests in libs/npm/resolution/graph.rs: link_package_not_on_registry (transitive dep) and link_package_not_on_registry_as_root (root req)
  • Added spec test tests/specs/npm/link_npm_package_not_on_registry/
  • All existing link_npm_package_* spec tests pass (7/7)
  • All deno_npm crate tests pass (179/179)

🤖 Generated with Claude Code

When using the "links" field in deno.json to reference a local npm package
that has not been published to the npm registry, resolution would fail with
"npm package does not exist" because the code always fetched package info
from the registry before checking link packages.

Added a fallback mechanism that creates a synthetic NpmPackageInfo from link
package data when the registry returns PackageNotExists. This is applied at
all registry fetch call sites in the npm resolution code.

Closes #33010

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bartlomieju bartlomieju marked this pull request as draft March 27, 2026 08:13
@bartlomieju bartlomieju marked this pull request as ready for review March 27, 2026 16:15
@bartlomieju bartlomieju merged commit fa18175 into main Mar 30, 2026
222 checks passed
@bartlomieju bartlomieju deleted the fix/link-npm-package-not-on-registry branch March 30, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error importing local npm package when not published

1 participant