Skip to content

Commit cb74975

Browse files
authored
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.
1 parent cac28b5 commit cb74975

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

cli/npm/managed/resolvers/local.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,9 @@ async fn sync_resolution_with_fs(
518518
// linked into the root
519519
match found_names.entry(remote_alias) {
520520
Entry::Occupied(nv) => {
521-
alias_clashes
522-
|| remote.req.name != nv.get().name // alias to a different package (in case of duplicate aliases)
523-
|| !remote.req.version_req.matches(&nv.get().version) // incompatible version
521+
// alias to a different package (in case of duplicate aliases)
522+
// or the version doesn't match the version in the root node_modules
523+
alias_clashes || &remote_pkg.id.nv != *nv.get()
524524
}
525525
Entry::Vacant(entry) => {
526526
entry.insert(&remote_pkg.id.nv);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"tempDir": true,
3+
"steps": [
4+
{
5+
"args": "install",
6+
"output": "install.out"
7+
}
8+
]
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Download http://localhost:4260/@denotest/esm-basic
2+
Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
3+
Initialize @denotest/[email protected]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dependencies": {
3+
"@denotest/esm-basic": "latest"
4+
},
5+
"workspaces": ["package1"]
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"@denotest/esm-basic": "latest"
4+
}
5+
}

0 commit comments

Comments
 (0)