AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Create-Next-App Omits Next Steps Commands When Scaffolding From Built-In Templates

When using create-next-app without an example (i.e., built-in template), the CLI does not print the 'Inside that directory...' instructions because the hasPackageJson flag is never set to true in the template branch.

mediumConfidence 95%Next.jsAffected V16.5.0-Canary.1

Origin Analysis

In packages/create-next-app/create-app.ts, hasPackageJson is initialized to false and only set based on package.json existence in the example branch. The else branch that calls installTemplate for built-in templates never updates hasPackageJson, so the final conditional block that prints next steps is skipped.
Run `npx create-next-app@canary test-app --ts --app --skip-install` (or interactive default); wait for scaffolding to finish; observe that after 'Success! Created test-app at <path>' no additional command instructions are printed.

Fixing Code Block

} else { try { await installTemplate({ appName, root, packageManager, isOnline, template, }) hasPackageJson = true } catch (err) { console.error(err) process.exit(1) } }
The added assignment sets hasPackageJson to true after installTemplate successfully generates a built-in template project, which always includes a package.json. This causes the later conditional to print the standard next steps commands.

Edge Case Audit

Assumes all built-in templates always contain package.json. If a future template omits package.json, the CLI will incorrectly print npm commands. A more robust fix would check `existsSync(path.join(root, 'package.json'))` after installTemplate. Rollback: remove the added line; if false positives occur, switch to existence check.

Ecosystem Topology