Link to the code that reproduces this issue
https://github.com/yskszk63/nextjs-unexpected-js-eval
To Reproduce
npm run build
Current vs. Expected behavior
Current
$ npm run build
> build
> next build
▲ Next.js 15.2.0-canary.13
Creating an optimized production build ...
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
Error: 🙈
at Object.<anonymous> (/home/yskszk63/work/nextjs-unexpected-js-eval/node_modules/throw-error-on-load/throw.js:1:7)
at Module._compile (node:internal/modules/cjs/loader:1566:14)
at Object..js (node:internal/modules/cjs/loader:1718:10)
at Module.load (node:internal/modules/cjs/loader:1305:32)
at Function._load (node:internal/modules/cjs/loader:1119:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:220:24)
at Module.<anonymous> (node:internal/modules/cjs/loader:1327:12)
at mod.require (/home/yskszk63/work/nextjs-unexpected-js-eval/node_modules/next/dist/server/require-hook.js:65:28)
at require (node:internal/modules/helpers:136:16)
Export encountered an error on /page: /, exiting the build.
⨯ Static worker exited with code: 1 and signal: null
Expected behavior
The build completes successfully.
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Fri, 10 Jan 2025 00:39:41 +0000
Available memory (MB): 30844
Available CPU cores: 16
Binaries:
Node: 23.4.0
npm: 11.0.0
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 15.2.0-canary.13 // Latest available version is detected (15.2.0-canary.13).
eslint-config-next: N/A
react: 19.0.0
react-dom: 19.0.0
typescript: 5.7.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Module Resolution
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local)
Additional context
I want to get the path of an asset after build, but unintentionally the specified file is loaded.
Removing serverExternalPackages
from next.config.ts works as expected.
Next issue in about 19 hours