New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: correctly detect the active Node js version during headless installation #7801
Conversation
💖 Thanks for opening this pull request! 💖 |
But the same code is present here:
So you just need to replace But we also need to check where and how is |
@@ -187,7 +188,7 @@ const defaults = (opts: InstallOptions) => { | |||
}, | |||
lockfileDir: opts.lockfileDir ?? opts.dir ?? process.cwd(), | |||
lockfileOnly: false, | |||
nodeVersion: process.version, | |||
nodeVersion: opts.nodeVersion ?? getSystemNodeVersion(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be enough
nodeVersion: opts.nodeVersion ?? getSystemNodeVersion(), | |
nodeVersion: opts.nodeVersion, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that we pass process.version
. getSystemNodeVersion
will be used anyway inside package-is-installable
.
Congrats on merging your first pull request! 🎉🎉🎉 |
@zkochan yes I agree, I actually tried that first and I can confirm that it also solves the issue. But I wasn't sure if the resulting typing changes were going to be problematic or not. Thanks for the quick response! |
This is a proof of concept for fixing #5266.
When pnpm is bundled with node.js (via standalone installer), and
engine-strict=true
, pnpm falls back to using the bundled node.js.pnpm properly detects the system node.js version when installing new packages, but not when doing headless installs (i.e. when the lockfile is up to date).
I think the issue is the
extendOptions
function:pnpm/pkg-manager/core/src/install/index.ts
Line 234 in e71ca75
It sets
options.nodeVersion = process.version
, i.e. whatever node is bundled with pnpm.This doesn't seem to matter during the code path for non-headless installations.
But during headless installations, it prevents pnpm from checking the system Node.js version when checking package compatibility.