Failed to load external module with turbopack and bun
Link to the code that reproduces this issue
https://github.com/Haaxor1689/next-turbopack-issue-repro
To Reproduce
bun ibun --bun dev(--bun is important to run with bun runtime)
Current vs. Expected behavior
You get following error when importing anything from "@aws-sdk/client-s3".
Failed to load external module @aws-sdk/client-s3-ecbef8e33fd0b8f0: ResolveMessage: Cannot find module '@aws-sdk/client-s3-ecbef8e33fd0b8f0' from 'C:\Projects\reproduction-app\.next\dev\server\chunks\ssr\[root-of-the-server]__8c5801f7._.js'
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Available memory (MB): 65451
Available CPU cores: 16
Binaries:
Node: 23.10.0
npm: 10.9.2
Yarn: N/A
pnpm: 10.7.0
Relevant Packages:
next: 16.1.0-canary.14 // Latest available version is detected (16.1.0-canary.14).
eslint-config-next: N/A
react: 19.2.0
react-dom: 19.2.0
typescript: 5.9.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
Since Bun is not in next info - I'm using Bun v1.3.2
This issue was already reported once by me and closed as fixed here #86652. This solved the issue in 16.1.0-canary.10 for node runtime but the issue in bun runtime still persists.
Same issue here.
Turbopack build fails in Next.js 16 when thread-stream / pino / WalletConnect dependencies are installed.
I upgraded from Next.js 16.0.1 → 16.0.7 due to the security advisory:
https://nextjs.org/blog/CVE-2025-66478
At the same time, I also upgraded React because of the critical RSC vulnerability: https://react.dev/blog/2025/12/03/critical-security-vulnerability-in-react-server-components
"react": "19.2.0" → "19.2.1",
"react-dom": "19.2.0" → "19.2.1"
But the build did not start failing after the React upgrade. The failures began only after upgrading Next.js.
After moving to 16.0.7, my production build shows the same Turbopack errors reported in this issue (Missing module type, Unknown module type, Parsing ecmascript failed) originating from thread-stream test files.
Everything was working correctly in Next.js 16.0.1.
I am not using bun
I'm having the same issue with Turbopack build failures in a project where I have pino installed and upgraded Next.js from 16.0.1 to 16.0.7.
Although not ideal, using the --webpack flag on the build command, does build the project successfully.
I'm using [email protected] with:
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000
Available memory (MB): 65536
Available CPU cores: 10
Binaries:
Node: 22.20.0
npm: 10.9.3
Yarn: 1.22.22
pnpm: 10.7.1
Relevant Packages:
next: 16.0.7 // Latest available version is detected (16.0.7).
eslint-config-next: N/A
react: 19.2.1
react-dom: 19.2.1
typescript: 5.9.3
Next.js Config:
output: N/A
@catosaurusrex2003 and @CosAnca if you are not using Bun runtime then try canary 10 where my previous issue was fixed in. Canary 12+ should contain the security fix but I wasn't able to confirm that anywhere.
@CosAnca, @Haaxor1689
--webpack flag on the build command, works perfectly 👍 ,
thanks
Strange, https://github.com/vercel/next.js/pull/86697 should have fixed that.
Could you verify if running it with Node instead of Bun works fine? Then it seems like a bug in bun
Yes, running in node instead of bun works, or running with webpack and bun also works.
I recommend that you report this to bun then.
Here is the Bun issue.
@CosAnca, @Haaxor1689
--webpackflag on the build command, works perfectly 👍 , thanks
Update: The build is successful with webpack, but many of my the crypto wallet libraries I am using dont work well with webpack.
So I reverted back to turbopack and made the following changes for it to work
// next.config.ts
const nextConfig: NextConfig = {
/* config options here */
devIndicators: false,
turbopack: {
resolveAlias: {
pino: "pino/browser", // these were the libraries which were giving me error while bulding
"pino/lib/transport": "pino/browser",
"thread-stream": "./lib/empty.js",
},
},
};
// ./lib/empty.js
export default {};
export const empty = {};
@mischnic I am using node
Operating System:
Platform: linux
Arch: x64
Version: #36~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Oct 15 15:45:17 UTC 2
Available memory (MB): 31189
Available CPU cores: 12
Binaries:
Node: 22.16.0
npm: 11.5.1
Yarn: N/A
pnpm: 10.12.1
Relevant Packages:
next: 16.0.7 // Latest available version is detected (16.0.7).
eslint-config-next: N/A
react: 19.2.1
react-dom: 19.2.1
typescript: 5.9.3
Next.js Config:
output: N/A
Updating next.config.ts worked for me (turbopack and yarn v4):
const nextConfig: NextConfig = {
...
serverExternalPackages: ["pino"],
};
I confirm that adding "pino" into the serverExternalPackages config, successfully builds the app using pnpm and Turbopack now.
Thank you for the tip @kkoudelka
@kkoudelka and @CosAnca your issue should be fixed since canary10 with the previous issue, this only regards bun + turbopack
but I'll go try setting it as an external package and see if that helps in bun
Edit: nope, putting it to serverExternalPackages does not seem to fix this bun + turbopack issue, guess I have to suffer the webpack dev mode slowness