pnpm
pnpm copied to clipboard
PNPM install prints "Cannot read properties of undefined (reading 'name')"
Verify latest release
- [X] 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/[email protected]
Which operating systems have you used?
- [ ] macOS
- [X] Windows
- [ ] Linux
If your OS is a Linux based, which one it is? (Include the version if relevant)
No response
I can confirm the bug. It happens on pnpm versions 9.10.0 and 9.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
{
"name": "test",
"packageManager": "[email protected]+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b",
"dependencies": {
"@udecode/plate-ui-table": "^18.13.0",
"@udecode/plate-ui-toolbar": "^18.13.0"
}
}
.npmrc
auto-install-peers = false
To replicate:
$ pnpm install # while no pnpm-lock.yaml exists
$ pnpm dedupe # if pnpm-lock.yaml exists
also, for monorepo, in .npmrc shared-workspace-lockfile=false ✅ No error shared-workspace-lockfile=true ❌ Error
Experiencing same thing on Linux/WSL2. Any ideas how to debug or get stacktrace?
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
parents can be empty, and it seems like in that case the issue should NOT be added, so maybe it needs to be:
const { parents } = getLocationFromParentNodeIds(ctx)
if (!parents.length) continue
if (ctx.peerDependencyIssues.missing[peerName] == null) {
ctx.peerDependencyIssues.missing[peerName] = []
}
...
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 peerDependencyIssuesByProjects variable 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.
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.1 and breaks install/dedupe.
Experiencing the same here.
Still present in 9.12.2
@zkochan @KSXGitHub FYI this bug is install-blocking and affecting several users. @VanTanev was able to provide a minimal repro and isolate the part of the code as the root cause. Our organization will be prevented from upgrading PNPM from v9.9 until a fix or workaround is discovered. Thank you for your support.
I'm also seeing this in 9.12.3, although the install still seems to work from what I can tell. Downgrading to 9.9.0 seems to resolve the issue for now, as I don't want these errors to cause problems in CI.
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.
PR: https://github.com/pnpm/pnpm/pull/8745
Thank you @zkochan!
@zkochan a release with the fix would be appreciated. Thanks a lot!
released
released
Thank you for your support!
I had to move "workspaces": [ "packages/*" ],
from root package.json to pnpm-workspace.yaml
since I had
WARN The "workspaces" field in package.json is not supported by pnpm. Create a "pnpm-workspace.yaml" file instead.
that , in combination with downgrading to v9.9 , fixed the problem
I fix it using pnpm approve-builds before building it , if it can help anybody