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: special version node check #6509
Conversation
💖 Thanks for opening this pull request! 💖 |
@@ -6,7 +6,7 @@ export function getSystemNodeVersionNonCached () { | |||
if (process['pkg'] != null) { | |||
return execa.sync('node', ['--version']).stdout.toString() | |||
} | |||
return process.version | |||
return process.version.replace(/-.*$/, '') |
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.
why is this change required? Is it because it currently fails when checking if the node.js version satisfies the range in the engines field? I think in that case this change should be done before passing the version to semver. This function may be used also to print the node.js version and in that case I think we should return the correct version. Also, the way you did it, doesn't cover line 7.
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.
Yes, I installed version v21.0.0-nightly20230429c968361829
to test a function of node. When I run the project, its engine.node
field value ^14.18.0 || >=16.0.0
check will fail. Running it with npm will work fine.
I think in that case this change should be done before passing the version to semver.
You mean maybe we should change here?
if (wantedEngine.node && !semver.satisfies(currentEngine.node, wantedEngine.node)) { |
This function may be used also to print the node.js version and in that case I think we should return the correct version. Also, the way you did it, doesn't cover line 7.
I was negligent, I didn't think about these before. If we modify it in the above way, there is no need to change it here.
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.
Yes, that looks like the right place for the change.
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.
Ok, let me modify it.
Congrats on merging your first pull request! 🎉🎉🎉 |
@zkochan Thank you for your efficient and hard work! ❤️ |
--------- Co-authored-by: Zoltan Kochan <z@kochan.io>
refer to https://github.com/npm/cli/blob/bdab631b9847013dc4e8d4083669acf6c7bfb457/lib/cli.js#L16