Link to the code that reproduces this issue
https://github.com/alexop1000/nextjs-issue-reproduction/tree/master
To Reproduce
- Build your next application on Windows (npm run build)
- Build the docker image (for example,
docker build --pull --rm -f "Dockerfile" -t nexttest:latest ".")
- Run the docker image on a Linux machine, or on Docker desktop.
Current vs. Expected behavior
The user gets an internal error 500 when visiting your website. You get "Error: Cannot find module 'next/dist\client\components\static-generation-async-storage-external.js'" on server logs. The specifics can be found in this discussion.
Example error message output:
2023-11-09 10:52:50 ⨯ Error: Cannot find module 'next/dist\client\components\static-generation-async-storage.external.js'
2023-11-09 10:52:50 Require stack:
2023-11-09 10:52:50 - /usr/src/app/.next/server/app/_not-found.js
2023-11-09 10:52:50 - /usr/src/app/node_modules/next/dist/server/require.js
2023-11-09 10:52:50 - /usr/src/app/node_modules/next/dist/server/next-server.js
2023-11-09 10:52:50 - /usr/src/app/node_modules/next/dist/server/next.js
2023-11-09 10:52:50 - /usr/src/app/node_modules/next/dist/server/lib/start-server.js
2023-11-09 10:52:50 - /usr/src/app/node_modules/next/dist/cli/next-start.js
2023-11-09 10:52:50 - /usr/src/app/node_modules/next/dist/lib/commands.js
2023-11-09 10:52:50 - /usr/src/app/node_modules/next/dist/bin/next
2023-11-09 10:52:50 at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
2023-11-09 10:52:50 at /usr/src/app/node_modules/next/dist/server/require-hook.js:54:36
2023-11-09 10:52:50 at Module._load (node:internal/modules/cjs/loader:901:27)
2023-11-09 10:52:50 at Module.require (node:internal/modules/cjs/loader:1115:19)
2023-11-09 10:52:50 at mod.require (/usr/src/app/node_modules/next/dist/server/require-hook.js:64:28)
2023-11-09 10:52:50 at require (node:internal/modules/helpers:130:18)
2023-11-09 10:52:50 at 5319 (/usr/src/app/.next/server/app/_not-found.js:1:612)
2023-11-09 10:52:50 at t (/usr/src/app/.next/server/webpack-runtime.js:1:127)
2023-11-09 10:52:50 at 2564 (/usr/src/app/.next/server/chunks/349.js:1:117695)
2023-11-09 10:52:50 at t (/usr/src/app/.next/server/webpack-runtime.js:1:127) {
2023-11-09 10:52:50 code: 'MODULE_NOT_FOUND',
2023-11-09 10:52:50 requireStack: [
2023-11-09 10:52:50 '/usr/src/app/.next/server/app/_not-found.js',
2023-11-09 10:52:50 '/usr/src/app/node_modules/next/dist/server/require.js',
2023-11-09 10:52:50 '/usr/src/app/node_modules/next/dist/server/next-server.js',
2023-11-09 10:52:50 '/usr/src/app/node_modules/next/dist/server/next.js',
2023-11-09 10:52:50 '/usr/src/app/node_modules/next/dist/server/lib/start-server.js',
2023-11-09 10:52:50 '/usr/src/app/node_modules/next/dist/cli/next-start.js',
2023-11-09 10:52:50 '/usr/src/app/node_modules/next/dist/lib/commands.js',
2023-11-09 10:52:50 '/usr/src/app/node_modules/next/dist/bin/next'
2023-11-09 10:52:50 ]
2023-11-09 10:52:50 }
Verify canary release
Provide environment information
Operating System:
Platform: linux
Arch: arm64
Version: SMP Fri Aug 18 21:57:12 PDT 2023
Binaries:
Node: 20.8.1
npm: 10.1.1
Yarn: 1.22.19
pnpm: N/A
Relevant Packages:
next: 14.0.0
react: 18.2.0
react—don: 18.2.0
typescript: 5.2.2
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
App Router, Operating System (Windows, MacOS, Linux)
Additional context
If you look in the discussion forum, you can see that it works in version 13.4.19.
You can also see that people have identified the specific problem that needs to be resolved.
The line:
return `commonjs ${localRes.replace(/.*?next[/\\]dist/, "next/dist")}`
Has to be replaced with:
return `commonjs ${localRes.replace(/.*?next[/\\]dist/, "next/dist").replace(/\\/g, "/")}`
In the file "\node_modules\next\dist\build\handle-externals.js", to generate the correct paths.
Link to the code that reproduces this issue
https://github.com/alexop1000/nextjs-issue-reproduction/tree/master
To Reproduce
docker build --pull --rm -f "Dockerfile" -t nexttest:latest ".")Current vs. Expected behavior
The user gets an internal error 500 when visiting your website. You get "Error: Cannot find module 'next/dist\client\components\static-generation-async-storage-external.js'" on server logs. The specifics can be found in this discussion.
Example error message output:
Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router, Operating System (Windows, MacOS, Linux)
Additional context
If you look in the discussion forum, you can see that it works in version 13.4.19.
You can also see that people have identified the specific problem that needs to be resolved.
The line:
Has to be replaced with:
In the file "\node_modules\next\dist\build\handle-externals.js", to generate the correct paths.