next.js: Build time error: Can't resolve @swc/helpers/...
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
> ./node_modules/.bin/next info
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000
Binaries:
Node: 18.15.0
npm: 9.6.4
Yarn: N/A
pnpm: 8.2.0
Relevant packages:
next: 13.3.1-canary.16
eslint-config-next: 13.3.1-canary.16
react: 18.2.0
react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue
https://github.com/jianliao/nextjs-rsp-bug
To Reproduce
- Git clone https://github.com/jianliao/nextjs-rsp-bug
- npm i
- npm run build
The issue is exactly same as #38192.
Describe the Bug
After upgrade to next@13.3.1-canary.16
, next build will fail with below error messages:
> nextjs-rsp-table@0.1.0 build
> next build
warn - You have enabled experimental feature (appDir) in next.config.js.
warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
info - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback
Failed to compile.
./node_modules/@internationalized/date/dist/import.mjs
Module not found: Can't resolve '@swc/helpers/src/_class_private_field_init.mjs'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/@react-spectrum/calendar/dist/import.mjs
./node_modules/@adobe/react-spectrum/dist/import.mjs
./app/page.tsx
./node_modules/@internationalized/date/dist/import.mjs
Module not found: Can't resolve '@swc/helpers/src/_define_property.mjs'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/@react-spectrum/calendar/dist/import.mjs
./node_modules/@adobe/react-spectrum/dist/import.mjs
./app/page.tsx
./node_modules/@react-aria/focus/dist/import.mjs
Module not found: Can't resolve '@swc/helpers/src/_define_property.mjs'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/@react-spectrum/actiongroup/dist/import.mjs
./node_modules/@adobe/react-spectrum/dist/import.mjs
./app/page.tsx
./node_modules/@react-stately/collections/dist/import.mjs
Module not found: Can't resolve '@swc/helpers/src/_define_property.mjs'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/@adobe/react-spectrum/dist/import.mjs
./app/page.tsx
./node_modules/@react-stately/grid/dist/import.mjs
Module not found: Can't resolve '@swc/helpers/src/_define_property.mjs'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/@react-stately/table/dist/import.mjs
./node_modules/@react-spectrum/table/dist/import.mjs
./node_modules/@adobe/react-spectrum/dist/import.mjs
./app/page.tsx
> Build failed because of webpack errors
info - Creating an optimized production build .%
Expected Behavior
Build success.
Which browser are you using? (if relevant)
Chrome 113.0.5672.35
How are you deploying your application? (if relevant)
next build
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 19
- Comments: 62 (19 by maintainers)
Commits related to this issue
- fix(es/helpers): Add `src/*.mjs` entry back (#7328) **Related issue:** - https://github.com/vercel/next.js/issues/48593 — committed to swc-project/swc by magic-akari a year ago
- fix: Update `@swc/helpers` to `v0.5.1` (#48808) ### What? Update `@swc/helpers` to `v0.5.1`. ### Why? Webpack merges `@swc/helpers@v0.4.x` and `@swc/helpers@v0.5.x`, due to `resolve.alias` config ... — committed to vercel/next.js by kdy1 a year ago
- Update resolve rule for `@swc/helpers` (#48980) ### What? Update resolve rule for `@swc/helpers` => `node_modules/@swc/helpers` to `@swc/helpers/_` => `node_modules/@swc/helpers/_` to select only `@... — committed to vercel/next.js by kdy1 a year ago
Maybe this could be given extra attention? This literally bombs when trying to follow the Getting Started guide. Thanks!
Having this problem in
v13.3.1
. Using simple turborepo here.How to fix this bug in nextjs@12.x ?
npm overrides: https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides
yarn resolutions: https://yarnpkg.com/configuration/manifest#resolutions
pnpm.overrides https://pnpm.io/package_json#pnpmoverrides
I had such error for
react-aria
on"next": "13.3.1"
. Downgrading to"next": "13.3.0"
helped.P.S. probably you need to set exact version, if you already have
13.3.1
in lock file changing version from"next": "^13.3.1"
to"^13.3.0"
. will probably make no effect since the versions are compatible because of^
I was about to ask the same thing
I’m also wondering if somebody knows how to fix this with Next 12.x, using patch-package or whatever.
yeah, I also noticed that some early version work if you don’t use the
^
For people looking for a temporary fix you can use this workaround
https://github.com/vercel/next.js/issues/48577
this issue is not only attached to @swc/helpers this issue es related to all packages that has different versions installed in monorepo. This is failing only in this because the helpers change from the v0.4 to the 0.5 the structure so when resolving to the last version that src folder does not exist
also if you use turbopack the issue does not exist.
Getting the same with
@internationalized/date
- seems related to Adobe packages.It’s now fixed 😄
You must update
@swc/helpers
ofnext
package. If you are usingyarn
, you can do likehttps://github.com/kdy1/bug-next-12-swc-helpers/blob/140abb8b18ccfac263356cc686c061bbfba795f5/package.json#L16-L18
Thank you @devongovett and @magic-akari
Maybe someone from the @vercel team can patch next@12 to fix it issue
I have the issue on 13.3.0 oddly.
Confirmed. The issue had been fixed on
next@13.3.2-canary.6
for my reproducer repo.I have posted a solution in the meantime this get resolved, look here for the webpack simple plugin
here just in case:
https://github.com/vercel/next.js/issues/48593#issuecomment-1519111776
When using 13.2.x everything works fine. This is 4 days open and literally makes the framework unusable, will anyone fix this?
I’m getting the same errors using Turborepo. My additional information mimic for the original reports but I also hopped over to a machine to confirm the results and those details are below. So I’ve received the same result on both MacOS and Windows. I, too am starting from ‘getting started’ so this Next app is brand new, but been a non-starter as this presents itself right out the gate.
Thanks and let me know if I can provide any better detail. I can post my macOS details as needed but they mimic the og post as mentioned earlier.
I still have this issue with Jest when using Next 13.4.4. The latest Next version that works for me is 13.3.0.
v13.3.2 officially released to solve this issue. See: https://github.com/vercel/next.js/releases/tag/v13.3.2
I still have this issue with Jest and
@swc/jest
also errors coming from the react-aria packagesfor some reason im getting this error in next v13.2.4 . It was working until I installed @react-aria/i18n, I can’t figure out why
@huykon It’s released in v13.3.2-canary.6
do we have any release versions to fix this issue?
Thanks! Resolved ✅
Good tip actually, I was under the assumption I had to go back to 12.2.x because I use
~
which uses latest patch version. So~13.3.0
=13.3.1
I am pretty sure this issue was introduced by version v13.3.1-canary.12.