ES Modules may not assign module.exports or exports.*, Use ESM export syntax #66017
Labels
bug
Issue was opened via the bug report template.
Module Resolution
Module resolution (CJS / ESM, module resolving)
SWC
Related to minification/transpilation in Next.js.
Webpack
Related to Webpack with Next.js.
Link to the code that reproduces this issue
https://github.com/maulik1729/es-module-next-bug
To Reproduce
Current vs. Expected behavior
Current behavior:
When I run yarn build it is giving below error Collecting page data .Error: ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: 302 at Object.set [as exports] (/Users/maulikpatel/Desktop/next-14/.next/server/webpack-runtime.js:1:611) at 302 (/Users/maulikpatel/Desktop/next-14/.next/server/pages/index.js:1:1763) at t (/Users/maulikpatel/Desktop/next-14/.next/server/webpack-runtime.js:1:142) at 910 (/Users/maulikpatel/Desktop/next-14/.next/server/pages/index.js:1:703) at t (/Users/maulikpatel/Desktop/next-14/.next/server/webpack-runtime.js:1:142) at /Users/maulikpatel/Desktop/next-14/.next/server/pages/index.js:1:2259 at t.X (/Users/maulikpatel/Desktop/next-14/.next/server/webpack-runtime.js:1:1009) at /Users/maulikpatel/Desktop/next-14/.next/server/pages/index.js:1:2230 at Object.<anonymous> (/Users/maulikpatel/Desktop/next-14/.next/server/pages/index.js:1:2295) at Module._compile (node:internal/modules/cjs/loader:1256:14)
Expected behavior:
yarn build
should run successfully without error.Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 Binaries: Node: 18.18.2 npm: 9.8.1 Yarn: 1.22.21 pnpm: 9.0.6 Relevant Packages: next: 14.1.0 eslint-config-next: N/A react: 18.3.1 react-dom: 18.3.1 typescript: 5.4.5 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Module Resolution, SWC, Webpack
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
Same code is working for NextJS 14.0.4 but when I am trying to upgrade it to NextJS 14.1.0 it is breaking.
The text was updated successfully, but these errors were encountered: