pnpm: PNPM install prints "Cannot read properties of undefined (reading 'name')"
Verify latest release
- I verified that the issue exists in the latest pnpm release
pnpm version
9.10.0
Which area(s) of pnpm are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue or a replay of the bug
No response
Reproduction steps
pnpm install
Describe the Bug
After pnpm install says it’s finished,
After postinstall hook says it’s finished,
usually at the part where it prints a bunch of warnings about peer dependencies, pnpm just prints the one line:
"Cannot read properties of undefined (reading 'name')"
There is no stack trace available.
We are using @pnpm/exe
The node_modules folder is populated after install – but I’m concerned the process may have exited prematurely. Is there a way to set verbose logging or to debug exactly how this error is being printed?
Expected Behavior
I would normally expect to not see this error printed, and instead see a bunch of warnings about peer dependencies printed at the end.
EDIT: the issue repros in 9.10.0 but not 9.9.0, so the issue must have been introduced between versions.
Which Node.js version are you using?
Whatever is shipped with @pnpm/exe@9.10.0
Which operating systems have you used?
- macOS
- Windows
- Linux
If your OS is a Linux based, which one it is? (Include the version if relevant)
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 13
- Comments: 17 (3 by maintainers)
Commits related to this issue
- fix: rendering of missing peer dependencies output close #8538 — committed to pnpm/pnpm by zkochan 2 years ago
- fix: rendering of missing peer dependencies output (#8745) close #8538 — committed to pnpm/pnpm by zkochan 2 years ago
- fix: rendering of missing peer dependencies output (#8745) close #8538 — committed to jdalton/pnpm by zkochan 2 years ago
- chore(deps): update pnpm to v9.15.1 (#27) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [pnpm](https://pnpm.io) ([source](https://github.com/pnpm/p... — committed to jelmore1674/build-changelog by deleted user 2 years ago
Since another bug introduced by https://github.com/pnpm/pnpm/commit/96aa4bc4a3085ec886fd5d27d12e56584ab6bf0f was recently fixed, I just wanted to say that the bug still exists in pnpm
9.12.1and breaks install/dedupe.Still present in 9.12.2
Hey @zkochan, I have bisected the breaking commit to: https://github.com/pnpm/pnpm/commit/96aa4bc4a3085ec886fd5d27d12e56584ab6bf0f
The root cause seems to be this: https://github.com/pnpm/pnpm/blob/9cfee8f46104f577af7fc8d6fdd69eddbd1ed2f2/pkg-manager/resolve-dependencies/src/resolvePeers.ts#L437-L445
parentscan be empty, and it seems like in that case the issue should NOT be added, so maybe it needs to be:The error is printed by this call: https://github.com/pnpm/pnpm/blob/9cfee8f46104f577af7fc8d6fdd69eddbd1ed2f2/pkg-manager/core/src/install/index.ts#L1361-L1364
And here is an example of the value of the
peerDependencyIssuesByProjectsvariable that I see in my reproduction repository: https://gist.github.com/VanTanev/3f3325091f64d6bff447509842fa22a8 - search for"parents": []I would contribute a PR, but I honestly don’t understand the issue well enough, apologies.
also, for monorepo, in .npmrc shared-workspace-lockfile=false ✅ No error shared-workspace-lockfile=true ❌ Error
PR: https://github.com/pnpm/pnpm/pull/8745
This seems to be an issue with reporting only (so install actually succeeds but the warning about missing peers is not printed). Not sure how to fix it properly right now. I guess we could just skip the missing peer dependency warning in this case. It’ll still be printed but not for all occurrences.
I’ll make a PR.
@zkochan a release with the fix would be appreciated. Thanks a lot!
I’m also seeing this in
9.12.3, although the install still seems to work from what I can tell. Downgrading to9.9.0seems to resolve the issue for now, as I don’t want these errors to cause problems in CI.I can confirm the bug. It happens on pnpm versions
9.10.0and9.11.0. It happens on MacOS as well.Reproduction repo: https://github.com/VanTanev/pnpm-reproduce-8538
Here is a minimum reproduction setup:
package.json.npmrcTo replicate: