Specify exact Node/npm versions for development - #2432
Open
TheJaredWilcurt wants to merge 3 commits into
Open
Conversation
This file contains hidden or 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
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.
Description
main)Fixes Issue:
The
devEnginesfield is an official part of the Node/npmpackage.jsonspecification. Unlikeengineswhich communicates what versions of Node are compatible with the built version of the library,devEnginescommunicates what version of Node and npm is used for local development, when working on the library. Since devDependencies, like ESLint, may require newer Node/npm versions to work than the built code. This makes it clear to contributors what Node and npm version they should switch to when working with this repo. There are many tools (Volta, Proto, Mise, etc) that can automatically download and switch to the exact version of Node/npm specified in thepackage.json.My process for determining the Node/npm versions without devEngines:
npm ichanges thepackage-lock.jsonfrom version 3 to version 1. Revert back.CONTRIBUTING.mdwhich mentions "Node 16+"npm iand see the following errors about mismatched version:commanderrequires Node>=20, and that is compatible with the other engine errors, update to 20:npm iwith these versions works without errors and does not mutate thepackage-lock.jsonat all.npm ialso works and causes no changes to thepackage-lock.jsonmake jsworks without any errors or issues.You can set the devEngines to a less specific value or a range, like
"version": "24.x.x"or"version": ">=24", but it's considered a best practice to specify the exact version to ensure everyone working on a project is using the exact version. There can be slight differences that cause issues, even within minor releases. For example, 18.16.0 made a small change to date formatting which caused unit tests around time zones to start breaking, which was then undone in 18.18.0 when caught. This affected my team at work where 3 devs were on Node 18.14.0, 18.16.0, and 18.20.0, and couldn't figure out why one of them kept getting failing tests and the other two didn't. Once everyone was on the same version, weird issues like that go away. This is also true for npm.TLDR:
enginesis best being the lowest version the library can work with and accepting a large range (you are already doing this 👍)devEnginesis best being the latest version of Node/npm that works when developing the library and it should be an exact version for both (Node/npm) to avoid issues when working on the library.devEnginesis up to you. Some do it roughly once a year when new LTS versions come out. However, if like me, you use a tool like Proto that switches your Node versions automatically, so you can never be on the wrong version, you may update the Node version often, even on every PR or new release.Before Merge Checklist
These items can be completed after PR is created.
Python implementation (NA if HTML beautifier)Added Tests to data file(s)Added command-line option(s) (NA ifREADME.md documents new feature/option(s)