Closed yayashn closed 3 weeks ago
Payload is fully ESM only and thus we don't export or support CJS modules.
You should import withPayload like so
import { withPayload } from '@payloadcms/next/withPayload'
See this file from our 3.0 demo as a full example https://github.com/payloadcms/payload-3.0-demo/blob/main/next.config.mjs
Note that the next config is also .mjs
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.
Link to reproduction
No response
Environment Info
Describe the Bug
Get this error upon installing payload on a project that does not use imports in next.config.js:
Duplicating/renaming the file with the .cjs extension in node_modules manually fixes this /node_modules/@payloadcms/next/dist/cjs/withPayload.js
->
/node_modules/@payloadcms/next/dist/cjs/withPayload.cjs`.Reproduction Steps
-> Use
const { withPayload } = require("@payloadcms/next/withPayload");
in next.config.js. You can refer to this project: https://github.com/yayashn/payload-catalystAdapters and Plugins
No response