-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[BUG] npm version --workspaces
still doesn't update dependencies
#7843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
After further testing and analysis, here’s what I found: inter-workspace dependency updates in npm workspaces! Behavior Observed: When running npm version patch -ws --save or npm version minor -ws --save, inter-workspace dependencies (e.g., package-b depending on package-a) update as expected. This behavior aligns with npm’s semver logic. Caret ranges like ^1.0.2 allow updates only within the 1.x.x range. Conclusion: This is not a bug; it’s the expected behavior of npm. To allow major version updates, you’ll need to adjust the semver range in the dependent workspace’s package.json. |
@kchindam-infy thank you for your analysis.
Before: {
"name": "package-b",
"version": "1.0.0",
"dependencies": {
"package-a": "^1.0.0"
}
} After: {
"name": "package-b",
"version": "1.0.1",
"dependencies": {
"package-a": "^1.0.1"
}
} But it doesn't work with a tilde. The inter-workspace dependency package-a is not updated:
Before: {
"name": "package-b",
"version": "1.0.0",
"dependencies": {
"package-a": "~1.0.0"
}
} After: {
"name": "package-b",
"version": "1.0.1",
"dependencies": {
"package-a": "~1.0.0"
}
} A major update only works once for updating the inter-workspace dependency version. Since a
Before: {
"name": "package-b",
"version": "1.0.0",
"dependencies": {
"package-a": ">=1.0.0"
}
} After: {
"name": "package-b",
"version": "2.0.0",
"dependencies": {
"package-a": "^2.0.0"
}
} As expected, a second run with
If a fixed version number is entered, there is no way to increment this inter-workspace dependency with |
I am running into the problem reported by @websolutions-hamburg that We would like to migrate from lerna to npm --workspaces and this would causes major version updates to break. Perhaps this issue should be reopened? @kchindam-infy ? |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
The issue #3403 still exists.
The command
npm version <version> --workspaces
does not update the dependencies nor the devDependencies in the package.json file.As documented here, the fix provided at the time unfortunately does not work: #4588 (comment)
Expected Behavior
npm version 2.0.0 --workspaces
should update all workspace package versions (currently does) and also update the package.json dependencies and devDependencies versions.Steps To Reproduce
package.json
:package.json
:npm version 2.0.0 --workspaces
Environment
The text was updated successfully, but these errors were encountered: