Skip to content

Bug fix: command hints not displayed after completion of create-next-app #81612

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

Open
wants to merge 3 commits into
base: canary
Choose a base branch
from

Conversation

suwakei
Copy link

@suwakei suwakei commented Jul 14, 2025

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.

Success! Created my-app at /path/to/my-app
Inside that directory, you can run several commands:

  npm run dev
    Starts the development server.

  npm run build
    Builds the app for production.

  npm start
    Runs the built app in production mode.

We suggest that you begin by typing:

  cd my-app
  npm run dev

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 with false.

let hasPackageJson = false

2. --example Processing if option is specified:

  • Download the sample from GitHub.
  • Check if package.json exists in the sample and set hasPackageJson to true or false.
if (example) {
  // ...
  hasPackageJson = existsSync(packageJsonPath) // Correctly set here
  // ...
}

3. --example Handle if option is not specified:

  • Call the function installTemplate to create a project template containing package.json.
  • Problem: Although this installTemplate function creates package.json, its caller does not update the hasPackageJson value.
} else {
  // ...
  await installTemplate({
    // ...
  })
  // *** The process of updating hasPackageJson to true is missing here. ***
}

4. Finally, the process displays a guidance message:

if (hasPackageJson) { //If example is not used, this will be false.
  console.log('Inside that directory, you can run several commands:')
  // ...
}
  • The guidance message is displayed only if 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 creates package.json,
add a line that sets hasPackageJson to true immediately after the call completes.

      turbopack,
      rspack,
    })
    +++ hasPackageJson = true
  }

  if (disableGit) {

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.

@ijjk ijjk added the create-next-app Related to our CLI tool for quickly starting a new Next.js application. label Jul 14, 2025
@ijjk
Copy link
Member

ijjk commented Jul 14, 2025

Allow CI Workflow Run

  • approve CI run for commit: 7cc9a3f

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

@suwakei
Copy link
Author

suwakei commented Jul 14, 2025

Hi! This PR is ready for review. Please approve the CI run when possible 🙇
(Let me know if anything needs adjustment!)

@suwakei
Copy link
Author

suwakei commented Jul 16, 2025

Hi! Just following up to see if there's anything I can improve in this PR 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-next-app Related to our CLI tool for quickly starting a new Next.js application.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants