-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[ENHC] Create Yarn
constraints to validate node
version
#10542
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Yarn
constraints to validate node
version
14de555
to
edff2a1
Compare
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.
PR Summary
This PR adds Yarn constraints to validate Node.js version compatibility, addressing frequent support requests related to version mismatches.
- Added
enableConstraintsChecks: true
in.yarnrc.yml
to enable Yarn's constraints feature - Created new
yarn.config.cjs
file that implements Node.js version validation using semver - Added
engineStrict: true
topackage.json
to enforce Node.js version requirements - Added
@yarnpkg/types
as a dev dependency to support type checking in the constraints configuration - Implementation checks current Node version against required version (^18.17.1) and throws clear error messages when mismatched
3 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
prastoin
commented
Feb 27, 2025
charlesBochet
approved these changes
Feb 27, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
This is PR is a suggestion ! And should be discussed
With yarn
^4
, during installation won't raise an error if current dev env does not satisfies theengines
policy.We have usually 10+ contributors support request regarding higher node version issue per week
I would have preferred a very declarative integration using npm engines but this does not seems to be natively supported by
yarn
We should keep in mind that this might block any machines from our CICD if they have diff node version installed ( such as running the project on a different node version could result in bugs too )
Implem
Created a yarn constraints run after each installation that checking if current node version satisfies defined engines range ( might also be done for others engines entries )
I assume we will always have the same engines policy for every packages, at least that's not a consideration from now
Further
We could refactor our package.json engines into only one using
Yarn.set
etcResource
Note
preInstall
hook as won't be effective on fresh installdevEngines
field pnpm/pnpm#8153 )Conclusion
As always any suggestions are more than welcomed !