Skip to content

Packages published with peer dependencies still containing workspace protocol (pnpm + lerna) #3671

Closed

Description

@plouc

Current Behavior

I maintain nivo, and I recently moved to pnpm and upgraded lerna to ^6.6.1.

I published a new version of the packages a day ago, but someone reported the following error:

npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "workspace:": workspace:*

I use the workspace protocol for all packages defined within the repo.
I checked the content of one of the published package package.json, and found out that while dependencies (and devDependencies) versions are properly replaced:

"dependencies": {
    "@nivo/scales": "0.82.0"
},

peerDependencies aren't:

"peerDependencies": {
    "@nivo/core": "workspace:*"
},

I tried to run pnpm pack on one of the package to see how it was handling this, and it properly replaced the peerDependencies version: "@nivo/core": "0.82.0" while lerna didn't.

Expected Behavior

I would expect the peerDependencies to be replaced as well.

Steps to Reproduce

Please see this repository.

The command I run is pnpm lerna publish --exact, defined in the project's make file under the pkgs-publish target.

You can install the @nivo/[email protected] package to observe the issue.

Configuration

lerna.json

{
    "packages": ["packages/*", "api"],
    "version": "0.82.0",
    "npmClient": "pnpm",
    "useWorkspaces": true
}

Environment

 Environment info:

  System:
    OS: macOS 13.2
    CPU: (10) arm64 Apple M1 Max
  Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
  Utilities:
    Git: 2.39.2 - /usr/bin/git

Activity

  1. plouc commented on May 2, 2023

    @plouc
    Author

    Probably related to #3637.

  2. ghiscoding commented on May 2, 2023

    @ghiscoding

    also related to #2402 and #955

    There's currently 2 issues in Lerna's code related to this

    1. Lerna only ever does 1 dependency version replacement, as soon as a package name is found it will bump the version on that package but it will stop there (following this order: dependencies, then devDependencies, then optionalDependencies and then peerDependencies) and continue with the next package dependency in the list, in other words considering what is shown below, it will only replace the first one with the highest priority (in this case dependencies) and then since it already did the first occurrence of @nivo/core in dependencies, the action is considered as done on that dependency name and will continue to the next name and will never see/visit the next peer deps one with the same name
    "dependencies": {
        "@nivo/core": "workspace:*"  // this one will be found and replaced
    },
    "peerDependencies": {
        "@nivo/core": "workspace:*"  // but this will be skipped because Lerna does not loop 
    },
    1. it was identified in Lerna that peer deps should never be updated as per this issue peerDependencies shouldn't be updated by lerna publish #1018 and later confirmed by Lerna maintainer in the same issue
  3. fahslaj commented on May 3, 2023

    @fahslaj
    Contributor

    As @ghiscoding said in his second point, peer deps will not be updated by lerna version or publish when bumping the version of packages for reasons mentioned in that thread.

    However, it does make sense for Lerna to still replace the workspace aliases in peerDeps with their appropriate version for consistency with npm/yarn/pnpm. After all, the workspace prefix should probably never appear in published package.json files.

  4. plouc commented on May 3, 2023

    @plouc
    Author

    After all, the workspace prefix should probably never appear in published package.json files.

    Yes, that was also my thinking, the workspace protocol doesn't really make sense once the packages are published and not in a workspace anymore.

  5. added
    accepting-prs
    on Nov 8, 2023
  6. JamesHenry commented on Jul 14, 2026

    @JamesHenry
    Member

    Closing for housekeeping as this shipped a while ago in #4203

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting-prstype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions