deno
8ae5320b - fix(resolver): fall through to .deno/ when BYONM node_modules version mismatches (#32981)

Commit
172 days ago
fix(resolver): fall through to .deno/ when BYONM node_modules version mismatches (#32981) ## Summary - When resolving `npm:pkg@version` in BYONM mode, the resolver would find a matching package.json dep via `intersects` (e.g., dep `^1.3.5` intersects req `1.3.6`) but then resolve the directory by package **name** only, returning whatever version was physically installed in `node_modules/` - If the installed version doesn't satisfy the requested version, the resolver now falls through to search `node_modules/.deno/` where the exact version may exist - This is the root cause of the issue reported in #32972 — with `--config` pointing to a `deno.json` with `nodeModulesDir: "manual"`, `deno run npm:pkg@X.Y.Z` would silently use whatever version was cached instead of honoring the requested version ### Root cause In `resolve_pkg_folder_from_deno_module_req`, the `Some((pkg_json, alias))` arm called `node_resolve_dir` which finds `node_modules/<pkg>` by name only and returned immediately without verifying the installed version satisfies `req.version_req`. The `.deno/` fallback (which does version matching) was only reached in the `None` arm. ### Fix After `node_resolve_dir` finds a path, read the resolved `package.json` and verify the installed version satisfies the requirement. If it doesn't match, fall through to `resolve_folder_in_root_node_modules` which scans `.deno/` entries with proper version matching. Closes #32972 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Parents
Loading