Bug fix: command hints not displayed after completion of create-next-app #81612
+4
−0
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.
Problem
When you create a new Next.js project using the
create-next-app
command, you will normally see the following guidance message at the end of the process.However, with this bug, if you create a project without the --example option (i.e., interactively select TypeScript, Tailwind CSS, etc.),
you will not see this guidance message.
Cause
The cause is that a flag (variable) called
hasPackageJson
,which determines whether or not to display the guidance message, has not been updated.
1. The variable
hasPackageJson
is initialized withfalse
.2.
--example
Processing if option is specified:package.json
exists in the sample and sethasPackageJson
totrue
orfalse
.3.
--example
Handle if option is not specified:installTemplate
to create a project template containingpackage.json
.installTemplate
function createspackage.json
, its caller does not update thehasPackageJson
value.4. Finally, the process displays a guidance message:
hasPackageJson
is true.In the case where
--example
was not used,hasPackageJson
remained false, resulting in a bug where the final guidance message was not displayed.Fix
The fix is quite simple: since the
installTemplate
function always createspackage.json
,add a line that sets
hasPackageJson
totrue
immediately after the call completes.This fix improves the user experience by ensuring that a consistent and friendly completion message is always displayed,
regardless of how the project was created.