Skip to content

Dependencies sorting in generated package.json causes unnecessary git diffs #77679

Open
@diegomais

Description

@diegomais

Link to the code that reproduces this issue

https://github.com/diegomais/nextjs-issue-reproduction

To Reproduce

  1. Create a new project by running: npx create-next-app@latest --use-pnpm
  2. Add a new dependency by running: pnpm add @radix-ui/react-popover
  3. Package managers would reorder dependencies in package.json after installation, causing unnecessary git diffs

Current vs. Expected behavior

I expected to create-next-app to generate pre-sorted dependencies and devDependencies in package.json file, but I observed package managers sorting them after adding a new dependency and devDependency in package.json.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6031
  Available memory (MB): 36864
  Available CPU cores: 14
Binaries:
  Node: 22.14.0
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 9.15.4
Relevant Packages:
  next: 15.2.4 // Latest available version is detected (15.2.4).
  eslint-config-next: 15.2.4
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

create-next-app

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

This change improves the consistency of generated package.json files and makes them more predictable across different package managers. It's a small but useful improvement for maintainability and readability.

This was problematic because:

  • It created noise in git history
  • Made it harder to review actual dependency changes
  • Caused unnecessary merge conflicts
  • Required manual sorting to maintain consistency

PR #77396 solves this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    create-next-appRelated to our CLI tool for quickly starting a new Next.js application.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions