Skip to content

[BUG] Unable to install untracked peer optional dependency #8464

@baileympearson

Description

@baileympearson

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

npm i <dependency name> succeeds with exit code 0 but the resultant dependency is not present, if <dependency name> is an untracked (not included in prod or dev dependencies) optional peer dependency.

I believe this is caused by #8431.

Expected Behavior

npm i <dependency name> should always install the dependency if the dependency has no version incompatibility issues.

Steps To Reproduce

Easiest way to see this is working in the mongodb package, because this scenario arose in our CI.

  1. Clone node-mongodb-native.
  2. run npm i
  3. install kerberos: npm i kerberos
  4. attempt to use kerberos: `node -p "require('kerberos')":
node:internal/modules/cjs/loader:1408
  throw err;
  ^

Error: Cannot find module 'kerberos'

Environment

  • npm: 11.5.0+
  • Node.js: doesn't matter
  • OS Name: doesn't matter
  • System Model Name: doesn't matter
  • npm config: doesn't matter

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 2secondary priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions