Skip to content

[BUG] npm install --package-lock-only crashes with install-strategy=linked in workspaces: Cannot read properties of undefined (reading 'children') #9105

@oscarmarina

Description

@oscarmarina

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

Running npm install --package-lock-only in a monorepo with install-strategy = "linked" in .npmrc crashes with:

npm warn reify The "linked" install strategy is EXPERIMENTAL and may contain bugs.
npm error Cannot read properties of undefined (reading 'children')

This also breaks any tool that internally relies on npm install --package-lock-only to sync the root lockfile — in our case, lerna version (Lerna v9.0.6).

Expected Behavior

npm install --package-lock-only should work correctly with install-strategy = "linked", or at minimum produce a meaningful error message instead of crashing with an unhandled TypeError.

Steps To Reproduce

  1. Create a monorepo with npm workspaces:
// package.json
{
  "name": "repro",
  "private": true,
  "workspaces": {
    "packages": ["packages/*"]
  }
}
  1. Set .npmrc:
  install-strategy = "linked"
  1. Have at least one workspace package under packages:

  2. Run:

npm install --package-lock-only
  1. Observe the crash:
npm warn reify The "linked" install strategy is EXPERIMENTAL and may contain bugs.
npm error Cannot read properties of undefined (reading 'children')

Workaround
Overriding the install strategy on the CLI for the lockfile-only command works:

npm install --package-lock-only --install-strategy=hoisted

In the context of Lerna, we added npmClientArgs in lerna.json

{
  "command": {
    "version": {
      "npmClientArgs": ["--install-strategy=hoisted"]
    }
  }
}

Real CI evidence:

Failing run using (install-strategy=linked):

lerna info auto-confirmed 
lerna info execute Skipping releases
lerna ERR! Error: Command failed with exit code 1: npm install --package-lock-only --ignore-scripts
lerna ERR! npm warn reify The "linked" install strategy is EXPERIMENTAL and may contain bugs.
lerna ERR! npm error Cannot read properties of undefined (reading 'children')

Passing run (with --install-strategy=hoisted override):

lerna info auto-confirmed 
lerna info execute Skipping releases
lerna info lifecycle lerna-monorepo@1.0.3~postversion: lerna-monorepo@1.0.3
✔ bumping version in package.json from 1.0.3 to 1.0.4
✔ bumping version in package-lock.json from 1.0.3 to 1.0.4
✔ outputting changes to CHANGELOG.md
lerna info git Pushing tags...
lerna success version finished

Both runs use the same codebase — the only difference is the npmClientArgs workaround in lerna.json

Environment

  • npm: 11.11.1
  • Node: v24.x
  • OS: ubuntu-latest (GitHub Actions), also reproduced on macOS Darwin arm64
  • Lerna: 9.0.6 (triggers npm install --package-lock-only --ignore-scripts internally)

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

    No branches or pull requests

    Issue actions