nextjs - ✅(Solved) Fix TypeError: Cannot redefine property: default when running `next dev` on fresh app (Next.js canary + pnpm) [1 pull requests, 8 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#92497Fetched 2026-04-09 07:50:00
View on GitHub
Comments
8
Participants
2
Timeline
13
Reactions
0
Timeline (top)
commented ×8closed ×1cross-referenced ×1issue_type_added ×1

Error Message

  1. Observe the error: However, the same error persists even after switching to the official canary version installed from npm:

Fix Action

Fixed

PR fix notes

PR #92498: fix: prevent crash "Cannot redefine property: default" when loading next.config

Description (problem / solution / changelog)

What?

Fixes a crash when running next dev on a fresh app using canary + pnpm:

TypeError: Cannot redefine property: default

Why?

When loading next.config, the result of normalizeConfig may include a default property due to ESM interop.

Applying Object.freeze directly on this object can cause property redefinition errors, especially in environments like pnpm with file-based dependencies.

How?

  • Normalize config using interopDefault
  • Safely unwrap default if present
  • Clone the normalized config before freezing to avoid descriptor conflicts

Reproduction

https://github.com/Akash504-ai/nextjs-cannot-redefine-property-default-repro

Notes

This fix has been validated using a fresh Next.js app with:

  • pnpm
  • canary version
  • empty next.config.js

The dev server now starts successfully without crashing.

Fixes #92497

Changed files

  • packages/next/src/server/config.ts (modified, +17/-6)

Code Example

pnpm create next-app .

---

Operating System:
  Platform: win32
  Arch: x64

Binaries:
  Node: v24.12.0
  pnpm: 10.33.0

Relevant Packages:
  next: 16.2.1-canary.26
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/Akash504-ai/nextjs-cannot-redefine-property-default-repro

To Reproduce

To Reproduce

  1. Create a new Next.js app using pnpm:

    pnpm create next-app .
  2. Select "Yes, use recommended defaults"

  3. Install dependencies (if not already installed): pnpm install

  4. (Optional) Create an empty next.config.js file: ni next.config.js

  5. Run the development server: pnpm dev

  6. Observe the error:

TypeError: Cannot redefine property: default at Object.freeze (<anonymous>)

Current vs. Expected behavior

Current behavior: Running pnpm dev on a freshly created Next.js app (using canary version) crashes immediately with:

TypeError: Cannot redefine property: default

Expected behavior: The development server should start successfully and serve the default Next.js app at http://localhost:3000.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64

Binaries:
  Node: v24.12.0
  pnpm: 10.33.0

Relevant Packages:
  next: 16.2.1-canary.26
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3

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

Turbopack

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

next dev (local)

Additional context

Initially, the issue appeared while using a locally linked Next.js build (file: dependency).

However, the same error persists even after switching to the official canary version installed from npm:

pnpm add [email protected]

The issue reproduces consistently on a fresh project with no modifications.

extent analysis

TL;DR

Downgrade the Next.js version to a stable release or wait for a fix in the canary version.

Guidance

  • Verify that the issue is specific to the canary version of Next.js by trying a stable version.
  • Check the Next.js GitHub repository for any open issues related to the "Cannot redefine property: default" error.
  • Try removing the next.config.js file, if present, to see if it affects the error.
  • Consider using a different package manager, like npm or yarn, to install dependencies and see if the issue persists.

Example

No code snippet is provided as the issue seems to be related to the Next.js version and configuration rather than a specific code error.

Notes

The issue appears to be specific to the canary version of Next.js and may be related to the Turbopack feature. The provided environment information and steps to reproduce the issue are helpful in identifying the potential cause.

Recommendation

Apply workaround: Downgrade to a stable Next.js version until the canary version is fixed, as the current version is causing the development server to crash immediately.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING