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

docs: Add section on workspace version bumps #8019

Open
wants to merge 3 commits into
base: latest
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions docs/lib/content/commands/npm-version.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,46 @@ This runs all your tests and proceeds only if they pass. Then runs your
After the commit, it pushes the new commit and tag up to the server, and
deletes the `build/temp` directory.

#### Workspaces and Inter-Dependencies

When using `npm workspaces`, you might have multiple packages that depend on one another. For example:

```json
// package-a/package.json
{
"name": "package-a",
"version": "1.0.2"
}

// package-b/package.json
{
"name": "package-b",
"version": "1.0.2",
"dependencies": {
"package-a": "^1.0.2"
}
}
```

#### Changes When Running `npm version -ws --save`

1. **Bump the versions in each workspace’s `package.json`.**
2. **Attempt to update cross-dependencies** where the new version fits into the declared semver range.

#### Note on `--save`
By default, `npm version -ws` will bump the versions in each workspace without automatically
updating dependency references across workspaces. Including the `--save` flag triggers a
minimal reify operation that updates references **if** your semver range allows it.
wraithgar marked this conversation as resolved.
Show resolved Hide resolved

For example, if a dependency is declared as `^1.0.2`, a minor bump from `1.0.2` to `1.1.0`
is valid under the caret range, so npm updates the reference to `^1.1.0`. However,
moving from `1.x.x` to `2.x.x` is outside of the caret range. In that case,
you must broaden the range (e.g., `">=1.0.0 <3.0.0"`, `"^1.0.0 || ^2.0.0"`, etc.) or
manually update it to allow a major bump.

It's important to note, Reify takes place even without the `--save` flag. However, in that case,
wraithgar marked this conversation as resolved.
Show resolved Hide resolved
package.json is not modified to reflect updated dependency references.

### See Also

* [npm init](/commands/npm-init)
Expand Down
Loading