Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES Modules may not assign module.exports or exports.*, Use ESM export syntax #66017

Open
maulik1729 opened this issue May 21, 2024 · 1 comment
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.

Comments

@maulik1729
Copy link

maulik1729 commented May 21, 2024

Link to the code that reproduces this issue

https://github.com/maulik1729/es-module-next-bug

To Reproduce

  1. clone the repo
  2. yarn install
  3. yarn build

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.

@maulik1729 maulik1729 added the bug Issue was opened via the bug report template. label May 21, 2024
@github-actions github-actions bot added Module Resolution Module resolution (CJS / ESM, module resolving) SWC Related to minification/transpilation in Next.js. Webpack Related to Webpack with Next.js. labels May 21, 2024
@BaileyMillerSSI
Copy link

Btw I think I am having similar problems and I found that version bump to be the same issue. #65707

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

2 participants