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

Lerna publish with pnpm workspace protocol is not updating package version when it is a dependency #3456

Closed
batusai513 opened this issue Dec 6, 2022 · 9 comments

Comments

@batusai513
Copy link

batusai513 commented Dec 6, 2022

Current Behavior

When I lerna publish, the dependencies that use the workspace protocol as version are not updated to the latest version in the generated package.json artifact uploaded to npm.

Expected Behavior

When I run lerna publish all packages affected which are dependencies of other packages should also be updated.

Steps to Reproduce

before lerna publish

{
  "name": "package-1",
  "version": "1.0.0"
}
{
  "name": "package-2",
  "version": "2.0.0",
  "dependencies": {
    "package-1": "workspace:1.0.0"
  }
}

after lerna publish in the repository code

{
  "name": "package-1",
  "version": "1.1.0"
}
{
  "name": "package-2",
  "version": "2.1.0",
  "dependencies": {
    "package-1": "workspace:1.1.0"
  }
}

But when installing the updated package from npm and inspection it's package.json file inside node_modules folder

{
  "name": "package-2",
  "version": "2.1.0",
  "dependencies": {
    "package-1": "1.0.0" //previous version
  }
}

Failure Logs / Configuration

lerna.json

{
  "$schema": "node_modules/lerna/schemas/lerna-schema.json",
  "packages": ["packages/*"],
  "version": "independent",
  "npmClient": "pnpm",
  "useWorkspaces": true,
  "changelogPreset": "conventionalcommits",
  "command": {
    "publish": {},
    "version": {
      "allowBranch": ["master"],
      "conventionalCommits": true,
      "createRelease": "github",
      "exact": true,
      "message": "chore(release): publish"
    }
  }
}

lerna-debug.log

Environment

@fahslaj fahslaj self-assigned this Dec 9, 2022
@fahslaj
Copy link
Contributor

fahslaj commented Dec 16, 2022

Hi @batusai513 Thank you for reporting this issue. Unfortunately, I was unable to reproduce this issue using the latest version of Lerna with the information that you have provided. In order for us to troubleshoot this issue, please kindly provide a minimal reproduction of the issue. You can use https://github.com/lerna/repro as a starting point.

@candy-Tong
Copy link

I also has similar problems.

It is ok when i release the package after write some code.
But I release again after release and do not add any code, it will get a error because i do not add any code and the verson of all the packages are not change. So it push fail.

lerna ERR! E403 You cannot publish over the previously published versions: 0.5.9.
 ELIFECYCLE  Command failed with exit code 1.

At this time, the verson in package.json will be change like this.
image

@Leksat
Copy link

Leksat commented Mar 14, 2023

I face the same issue as described in the first comment.

  • @amazeelabs/publisher depends on @amazeelabs/publisher-shared
  • I updated both packages (commit)
  • the following lerna publish (commit)
    • updated version of both packages from 2.0.1 to 2.0.2
    • updated the dependency in @amazeelabs/publisher as follows
      "@amazeelabs/publisher-elements": "workspace:^2.0.2"
      
      (change)

Everything seems perfectly fine, but in the version published on NPM, the dependency version is still ^2.0.1: https://www.runpkg.com/?@amazeelabs/publisher@2.0.2/package.json#22

@Leksat
Copy link

Leksat commented Mar 14, 2023

@fahslaj If I create a repro, should it publish to NPM? Or is there a way to tell lerna to keep the packed version locally rather than upload it to NPM?

@fahslaj
Copy link
Contributor

fahslaj commented Mar 16, 2023

@Leksat You could publish it to npm. If you'd prefer not to, then you could use Verdaccio to host a private npm registry locally to test your repro. You would set your npm registry to the verdaccio url (something like http://localhost:4873), perform the publish, then navigate to that verdaccio url to check the published assets.

@Leksat
Copy link

Leksat commented Mar 18, 2023

@fahslaj lerna/repro#10 I hope it helps :)

Leksat added a commit to AmazeeLabs/silverback-mono that referenced this issue Mar 23, 2023
This should reduce Renovate's warnings.

Also, this might help workaround lerna/lerna#3456
Leksat added a commit to AmazeeLabs/silverback-mono that referenced this issue Mar 23, 2023
This should reduce Renovate's warnings.

Also, this might help workaround lerna/lerna#3456
@Leksat
Copy link

Leksat commented Mar 23, 2023

Also, I have found that there is no issue if dependency versions are set to workspace:*.

Example

@fahslaj
Copy link
Contributor

fahslaj commented Mar 23, 2023

Thank you for the reproduction @Leksat ! I see the issue and will have a fix soon.

@fahslaj
Copy link
Contributor

fahslaj commented Mar 24, 2023

The fix for this has been released in Lerna 6.6.1 🎉

@fahslaj fahslaj closed this as completed Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants