Skip to content

[BUG] npm error Cannot read properties of undefined (reading 'extraneous') in monorepo setups with incorrect local package references #8199

Open
@domdomegg

Description

@domdomegg

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

  1. Set up an npm workspace with three packages: package1, package2 and package 3. Make package1 depend on package3
  2. Rename or delete package3, without updating package1
  3. Run an npm install or npm uninstall operation in package2 (this works fine)
  4. Run an npm install or npm uninstall operation in package2 (this now errors with the error npm error Cannot read properties of undefined (reading 'extraneous'))

Bizzarelly also at this point, going to the root of the repo and running npm ci will reset you back to step 3, so you can continue to manage one package at a time.

Expected Behavior

Either:

  • npm gives you a clear error about why your setup is now invalid
  • npm handles installing and uninstalling packages in other packages fine (like it did in step 3 above, rather than progressing to step 4 with the error)

Steps To Reproduce

See expected behaviour section.

MRE repository to follow shortly.

Environment

  • npm: 11.2.0
  • Node.js: v23.10.0
  • OS Name: macOS
  • System Model Name: macOS
  • npm config:
; "builtin" config from /opt/homebrew/lib/node_modules/npm/npmrc

prefix = "/opt/homebrew"

; "user" config from /Users/user/.npmrc

//registry.npmjs.org/:_authToken = (protected)

; node bin location = /opt/homebrew/Cellar/node/23.10.0_1/bin/node
; node version = v23.10.0
; npm local prefix = /Users/user/Documents/npm-repro
; npm version = 11.2.0
; cwd = /Users/user/Documents/npm-repro
; HOME = /Users/user
; Run `npm config ls -l` to show all defaults.

Activity

domdomegg

domdomegg commented on Apr 1, 2025

@domdomegg
Author

Minimal reproducible example repo: https://github.com/domdomegg/npm-8199-mre

(the bug is actually demonstrated in the CI via test.js)

domdomegg

domdomegg commented on Apr 1, 2025

@domdomegg
Author

More stacktrace:

15 verbose stack TypeError: Cannot read properties of undefined (reading 'extraneous')
15 verbose stack     at #loadLink (/usr/local/share/npm-global/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js:296:30)
15 verbose stack     at #resolveLinks (/usr/local/share/npm-global/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js:203:34)
15 verbose stack     at async #loadFromShrinkwrap (/usr/local/share/npm-global/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js:91:5)
15 verbose stack     at async Arborist.loadVirtual (/usr/local/share/npm-global/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js:41:7)
15 verbose stack     at async #loadActual (/usr/local/share/npm-global/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/load-actual.js:153:11)
15 verbose stack     at async Promise.all (index 0)
15 verbose stack     at async Arborist.reify (/usr/local/share/npm-global/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:131:5)
15 verbose stack     at async Install.exec (/usr/local/share/npm-global/lib/node_modules/npm/lib/commands/install.js:149:5)
15 verbose stack     at async Npm.exec (/usr/local/share/npm-global/lib/node_modules/npm/lib/npm.js:208:9)
15 verbose stack     at async module.exports (/usr/local/share/npm-global/lib/node_modules/npm/lib/cli/entry.js:67:5)
16 error Cannot read properties of undefined (reading 'extraneous')
domdomegg

domdomegg commented on Apr 1, 2025

@domdomegg
Author

WIP in #8200

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

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @domdomegg

      Issue actions

        [BUG] `npm error Cannot read properties of undefined (reading 'extraneous')` in monorepo setups with incorrect local package references · Issue #8199 · npm/cli