Skip to content
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

[BUG] npm version prepatch --save does not update dependencies #8171

Closed
2 tasks done
skanaar opened this issue Mar 20, 2025 · 2 comments
Closed
2 tasks done

[BUG] npm version prepatch --save does not update dependencies #8171

skanaar opened this issue Mar 20, 2025 · 2 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@skanaar
Copy link

skanaar commented Mar 20, 2025

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

This command correctly updates the dependencies of packages in a monorepo so all versions are in sync.
npm version patch --workspaces --save

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" }

This command does not update the dependencies of packages in a monorepo.
npm version prepatch --workspaces --preid=sluggy --save

Before

"name": "package-b",
"version": "1.0.0",
"dependencies": { "package-a": "^1.0.0" }

After

"name": "package-b",
"version": "1.0.1-sluggy.0",
"dependencies": { "package-a": "^1.0.0" }

This issue provides more background to this problem: #7843

Expected Behavior

npm version prepatch --workspaces --preid=x --save should behave in the same way as npm version patch --workspaces --save.

Steps To Reproduce

Environment

  • npm: 11.2.0
  • Node.js: 23.10.0
  • OS Name: macOS Sequioa
  • System Model Name: MacBook Pro
@skanaar skanaar added Bug thing that needs fixing Needs Triage needs review for next steps labels Mar 20, 2025
@milaninfy
Copy link
Contributor

I believe this is working as expected.
Your declared dependency for package A is ^1.0.0 and when you run npm version prepatch --workspaces --preid=x --save it tried to save but it's not satisfied with your declared range.

here is an example for your prepatch version is outside of the range specified.

const semver = require('semver')
semver.satisfies('1.0.1-sluggy.0', '^1.0.0')) // false
semver.satisfies('1.0.1-sluggy.0', '^1.0.1')) // false
semver.satisfies('1.0.1-sluggy.4', '^1.0.1-sluggy.0')) // true

@skanaar
Copy link
Author

skanaar commented Mar 20, 2025

Thanks for taking a look.

Ok. How would you use the npm version prepatch command here to actually generate a prerelease version of a set of packages in a monorepo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps
Projects
None yet
Development

No branches or pull requests

2 participants