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

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,
package.json is not modified to reflect updated dependency references.

### See Also

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