payload generate:importmap crashes on a new Next.js app

Aperta
#19,475 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Razepriv ci sta già lavorando.

Dal 13/11/2026.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
56/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
next.js, node.js, typescript
Ambito
backend, cli

Direzione di ricerca

Start by tracing how the Payload CLI loads its bin through the bundled tsx loader and how that path loads undici's CommonJS entry. Reproduce with Node 26.9.0, Payload 3.93.0, and a payload.config.ts, then run npx payload generate:importmap. Done means the CLI completes and writes the import map without the CacheStorage constructor error.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: core Bug Payload-OSS
Describe the Bug

payload generate:importmap crashes before it writes an import map. This happens on a brand-new Next.js app once payload.config.ts exists. The same crash happens on an existing app. Node was 26.9.0. Payload was 3.93.0.

TypeError: Illegal constructor
    at new CacheStorage (node_modules/undici/lib/web/cache/cachestorage.js:17:14)
    at Object.<anonymous> (node_modules/undici/index.js:177:25)
    at Object.transformer [as .js] (node_modules/tsx/dist/require-CBjy4Foe.mjs)

The Payload CLI loads its bin through the bundled tsx loader. That loader compiles undici's CommonJS entry, and CacheStorage's constructor check then throws.

next dev is a separate path. This report is only the CLI.

Link to the code that reproduces this issue

No public repository yet. Steps below create the reproduction from scratch with create-next-app and [email protected]. Happy to push that tree if a hosted repo is required.

Reproduction Steps
npx create-next-app@latest payload-next-repro --ts --tailwind --eslint --app --turbopack --use-npm --disable-git --yes
cd payload-next-repro
npm install [email protected]

Create payload.config.ts:

import { buildConfig } from 'payload'

export default buildConfig({
  collections: [],
  secret: 'test-secret',
})

Then run:

npx payload generate:importmap

Before payload.config.ts exists, the CLI starts and stops with "cannot find Payload config". After the file exists, it crashes in undici CacheStorage as shown above.

Which area(s) are affected?

area: core

Environment Info
Node.js: 26.9.0
npm: 11.19.1
next: 16.4.6
payload: 3.93.0
react: 19.3.0
OS: macOS, arm64
Package type: CommonJS (no "type": "module")
Lingua principale
TypeScript
Stelle
45.8k
Fork
4.4k
Merge medio
3g 4h
PR unite (30g)
210

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di payloadcms/payload

Tutte le issue di payloadcms/payload

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.