Skip to content
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

Increase specificity of .nvmrc version #57648

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

vcanales
Copy link
Member

@vcanales vcanales commented Jan 8, 2024

What?

Specify minimum minor version of node on .nvmrc to match the engine specified on package.json.

Why?

If I have previously installed a lower node version than what's required in package.json, using nvm use will succeed, but npm i will fail. This changes moves the failure in the chain, so that it will be nvm that'll let you know that you have to install a newer version of node.

Before:

➜  gutenberg git:(trunk) nvm use
Found 'gutenberg/.nvmrc' with version <20>
Now using node v20.9.0 (npm v10.1.0)
➜  gutenberg git:(trunk) npm i
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: gutenberg@17.4.1
npm ERR! notsup Not compatible with your version of node/npm: gutenberg@17.4.1
npm ERR! notsup Required: {"node":">=20.10.0","npm":">=10.2.3"}
npm ERR! notsup Actual:   {"npm":"10.1.0","node":"v20.9.0"}

After:

➜  gutenberg git:(increase-specificity-of-nvm-version) nvm use            
Found 'gutenberg/.nvmrc' with version <20.10>
N/A: version "v20.10" is not yet installed.

You need to run `nvm install` to install and use the node version specified in `.nvmrc`.

Trac ticket: https://core.trac.wordpress.org/ticket/59663.

@vcanales vcanales added the [Type] Build Tooling Issues or PRs related to build tooling label Jan 8, 2024
@vcanales vcanales requested a review from desrosj January 8, 2024 15:30
@desrosj
Copy link
Contributor

desrosj commented Jan 8, 2024

Hey @vcanales! Thanks for this one. I've gone and added the corresponding Trac ticket to the PR description so that this shows up there. There's already a suggestion and a PR there for this. I expressed some thoughts around the change in the ticket, and working to gather a bit more info before making a decision. But wanted to acknowledge that I saw this!

@vcanales
Copy link
Member Author

vcanales commented Jan 8, 2024

Thanks for taking a look, and for the extra context. I'll echo the questions that @kraftbj made over there, since I have the same ones:

IMO, if the version in nvmrc could be met by versions not meeting package.json, one or the other should be adjusted (e.g. why 20.10 vs 20.x as the minimum? Is there a functional reason why 20.10 is the minimum of the LTS?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Build Tooling Issues or PRs related to build tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants