-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
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
- Create a monorepo with npm workspaces:
// package.json
{
"name": "repro",
"private": true,
"workspaces": {
"packages": ["packages/*"]
}
}- Set .npmrc:
install-strategy = "linked"-
Have at least one workspace package under packages:
-
Run:
npm install --package-lock-only- 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=hoistedIn 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 finishedBoth 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)