Skip to content

peerDependency on @sourceloop/core breaks npm audit fix in workspace consumers #173

Description

@piyushsinghgaur1

Description

@sourceloop/audit-log declares @sourceloop/core as a peerDependency. In
consumer monorepos where @sourceloop/core is a local workspace package
(for example loopback4-microservice-catalog, where node_modules/@sourceloop/core
is a symlink to packages/core), npm cannot reconcile that peer during tree
re-resolution and fails with ERESOLVE.

The practical impact is that npm audit fix cannot run at all in those
consumers — it aborts before applying any remediation, so security fixes cannot
be applied through the normal workflow.

npm error code ERESOLVE
npm error While resolving: @sourceloop/audit-log@10.0.1
npm error Found: peer @sourceloop/core@"^21.0.0" from @sourceloop/audit-log@10.0.1
npm error Conflicting peer dependency: @sourceloop/core@21.0.0
npm error node_modules/@sourceloop/core

When this started

The peer was introduced in 9.1.0. Every release up to and including 9.0.0
declared no peerDependencies at all:

Version @sourceloop/core peer
6.0.0 – 9.0.0 none
9.1.0 ^20.0.6 (first appearance)
10.0.0 ^20.0.6
10.0.1 ^21.0.0

Consumers pinned to ^9.0.0 picked this up silently with no commit of their
own, as soon as 9.1.0 was published.

Diagnosis

The peer range itself is correct — the workspace @sourceloop/core is 21.0.0
and satisfies ^21.0.0. The failure is in npm's resolution of a registry
package's peer against a workspace-linked package, not a version mismatch.

Verified during investigation:

  • a plain npm install --package-lock-only in the consumer succeeds, so the
    existing tree is valid; only re-resolution fails
  • overrides pinning the peer from the consumer side does not help
  • npm audit fix --legacy-peer-deps works, but disables peer validation for the
    entire install

A controlled A/B test isolated the cause. Two tarballs identical except for the
peer metadata were installed into the consumer:

Variant Result
peerDependenciesMeta.@sourceloop/core.optional = true ERESOLVE gone, fix plan produced
identical tarball, flag absent ERESOLVE persists

Acceptance criteria

  • npm audit fix runs to completion in loopback4-microservice-catalog without --legacy-peer-deps

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions