From cb74975ab2b88a984c11a9bbb33ff2a36ccb2acb Mon Sep 17 00:00:00 2001 From: Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:11:43 -0700 Subject: fix(install): compare versions directly to decide whether to create a child node_modules dir for a workspace member (#26001) Fixes #25861. Previously we were attempting to match the version requirement against the version already present in `node_modules` root, and if they didn't match we would create a node_modules dir in the workspace member's directory with the dependency. Aside from the fact that this caused the panic, on second thought it just doesn't make sense in general. We shouldn't be semver matching, as resolution has already occurred and decided what package versions are required. Instead, we can just compare the versions directly. --- cli/npm/managed/resolvers/local.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'cli/npm/managed') diff --git a/cli/npm/managed/resolvers/local.rs b/cli/npm/managed/resolvers/local.rs index 59ba27d05..edc7c7ea0 100644 --- a/cli/npm/managed/resolvers/local.rs +++ b/cli/npm/managed/resolvers/local.rs @@ -518,9 +518,9 @@ async fn sync_resolution_with_fs( // linked into the root match found_names.entry(remote_alias) { Entry::Occupied(nv) => { - alias_clashes - || remote.req.name != nv.get().name // alias to a different package (in case of duplicate aliases) - || !remote.req.version_req.matches(&nv.get().version) // incompatible version + // alias to a different package (in case of duplicate aliases) + // or the version doesn't match the version in the root node_modules + alias_clashes || &remote_pkg.id.nv != *nv.get() } Entry::Vacant(entry) => { entry.insert(&remote_pkg.id.nv); -- cgit v1.2.3