fix: fail when exact template version does not exist#2764
Merged
fabriziocucci merged 1 commit intomainfrom Feb 6, 2026
Merged
Conversation
cipolleschi
approved these changes
Feb 6, 2026
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
Problem:
When running
npx @react-native-community/cli init MyApp --version "0.83.3", if the template for version0.83.3doesn't exist but0.83.2exists, the CLI would silently fall back to0.83.2instead of failing.This caused real problems:
rn-diff-purge breakage: The release job would succeed even when the requested template version didn't exist, because the CLI silently used a different template. This led to incorrect diffs being generated.
Confusing user experience: Users would see
Welcome to React Native 0.83.3in the console output, but when they checked theirpackage.json, they'd find a different version. This mismatch is confusing and can lead to debugging headaches.Solution:
Removed the minor version fallback logic in
getTemplateVersion(). The CLI now only matches exactMAJOR.MINOR.PATCHversions. If the requested version doesn't have a corresponding template, an error is thrown with a clear message.Changes
packages/cli/src/tools/npm.tsminorVersionhelperpackages/cli/src/commands/init/version.tspackages/cli/src/tools/__tests__/npm-test.tsundefinedfor non-existent versionsTest Plan