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 --workspaces version doesn't update dependencies #3403

Closed
1 task done
niemyjski opened this issue Jun 11, 2021 · 2 comments · Fixed by #4588
Closed
1 task done

[BUG] npm --workspaces version doesn't update dependencies #3403

niemyjski opened this issue Jun 11, 2021 · 2 comments · Fixed by #4588
Assignees
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@niemyjski
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

The npm --no-git-tag-version --workspaces version <version> command doesn't update package devDependencies or dependencies with the new version. I'd expect that workspace dependencies would be updated to match the new versions that were set.

Expected Behavior

npm --no-git-tag-version --workspaces version "2.0.0-alpha1" should update all workspace package versions (currently does) and also update the package dependency versions

Steps To Reproduce

  1. Setup a new npm workspace
  2. Create /packages/packagea :
{
  "name": "packagea",
  "version": "2.0.0-dev"
}
  1. Create ``/packages/packageb`:
{
  "name": "packageb",
  "version": "2.0.0-dev",
  "dependencies": {
      "packagea": "2.0.0-dev"
    }
}
  1. Run npm --no-git-tag-version --workspaces version "2.0.0-alpha1"
  2. notice the package versions are updated but the dependencies are not.

I have an existing setup located here: https://github.com/exceptionless/Exceptionless.JavaScript/tree/feature/workspaces that reproduces it (but package names are changed...)

I noticed this after getting the following error:

npm ERR! code ETARGET
npm ERR! notarget No matching version found for @exceptionless/core@2.0.0-dev.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

Environment

  • OS: Windows 10 latest
  • Node: v16.1.0
  • npm: 7.17.0
@niemyjski niemyjski added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Jun 11, 2021
niemyjski added a commit to exceptionless/Exceptionless.JavaScript that referenced this issue Jun 14, 2021
niemyjski added a commit to exceptionless/Exceptionless.JavaScript that referenced this issue Jun 22, 2021
@ruyadorno ruyadorno added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels Jan 24, 2022
@ruyadorno ruyadorno self-assigned this Mar 16, 2022
@wraithgar
Copy link
Member

wraithgar commented Mar 16, 2022

#4193
#3757

ruyadorno added a commit to ruyadorno/cli that referenced this issue Mar 17, 2022
When declaring dependencies to workspaces the common practice is to
refer to their version numbers, currently the cli adds a link reference
instead of the proper semver range when trying to install/declare as a
direct direct dependency one of its own workspaces.

This change fixes it by adding a new condition for handling workspace
edges when saving the current ideal tree.

Relates to: npm#3403
ruyadorno added a commit to ruyadorno/cli that referenced this issue Mar 17, 2022
When declaring dependencies to workspaces the common practice is to
refer to their version numbers, currently the cli adds a link reference
instead of the proper semver range when trying to install/declare as a
direct direct dependency one of its own workspaces.

This change fixes it by adding a new condition for handling workspace
edges when saving the current ideal tree.

Relates to: npm#3403
nlf pushed a commit that referenced this issue Mar 17, 2022
When declaring dependencies to workspaces the common practice is to
refer to their version numbers, currently the cli adds a link reference
instead of the proper semver range when trying to install/declare as a
direct direct dependency one of its own workspaces.

This change fixes it by adding a new condition for handling workspace
edges when saving the current ideal tree.

Relates to: #3403
ruyadorno added a commit to ruyadorno/cli that referenced this issue Mar 17, 2022
Adds a minimalistic reify step that updates the installed tree after a
version change within one of the configured workspaces when using any
of the workspaces config options.

It's also possible to use the `--save` config option in order to
auto update semver ranges of dependencies declarations accross dependent
`package.json` files.

Fixes: npm#3403
Relates to: npm/rfcs#556
Relates to: npm#3757
Relates to: npm#4193
ruyadorno added a commit to ruyadorno/cli that referenced this issue Mar 17, 2022
Adds a minimalistic reify step that updates the installed tree after a
version change within one of the configured workspaces when using any
of the workspaces config options.

It's also possible to use the `--save` config option in order to
auto update semver ranges of dependencies declarations accross dependent
`package.json` files.

Fixes: npm#3403
Relates to: npm/rfcs#556
Relates to: npm#3757
Relates to: npm#4193
ruyadorno added a commit to ruyadorno/cli that referenced this issue Mar 21, 2022
Adds a minimalistic reify step that updates the installed tree after a
version change within one of the configured workspaces when using any
of the workspaces config options.

It's also possible to use the `--save` config option in order to
auto update semver ranges of dependencies declarations accross dependent
`package.json` files.

Fixes: npm#3403
Relates to: npm/rfcs#556
Relates to: npm#3757
Relates to: npm#4193
fritzy pushed a commit that referenced this issue Mar 24, 2022
Adds a minimalistic reify step that updates the installed tree after a
version change within one of the configured workspaces when using any
of the workspaces config options.

It's also possible to use the `--save` config option in order to
auto update semver ranges of dependencies declarations accross dependent
`package.json` files.

Fixes: #3403
Relates to: npm/rfcs#556
Relates to: #3757
Relates to: #4193
@Roaders
Copy link

Roaders commented Mar 30, 2022

I came across this issue as well so wrote a script to fix it:
https://www.npmjs.com/package/workspace-version

just add:

version: "workspace-version -g"

to your root package.json scripts to update all child package json versions, update depenendency versions of siblings and add modified files to git (that's the -g) when you do $npm version patch. If you use it any feedback / issues much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants