Skip to content

Internal Server Error with [email protected] #2214

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

Closed
peakercope opened this issue Oct 3, 2023 · 25 comments
Closed

Internal Server Error with [email protected] #2214

peakercope opened this issue Oct 3, 2023 · 25 comments

Comments

@peakercope
Copy link

peakercope commented Oct 3, 2023

🐛 Bug Report

500 Internal Server Error with next.js version 13.5.4 in standalone build.

To Reproduce

  1. clone repo https://github.com/peakercope/material-ui-nextjs-pages-router-ts-example
  2. run pnpm i
  3. run pnpm build
  4. run node .next/standalone/server.js
  5. open in browser http://localhost:3000/

Actual behavior

Error page opened
image

Terminal error:

Error: Cannot find module 'core-js/modules/es.array.map.js'
Require stack:
- /material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_cziuidd23tbj2wqeyxn2xirvka/node_modules/next-i18next/dist/commonjs/config/createConfig.js
- /material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_cziuidd23tbj2wqeyxn2xirvka/node_modules/next-i18next/dist/commonjs/appWithTranslation.js
- /material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_cziuidd23tbj2wqeyxn2xirvka/node_modules/next-i18next/dist/commonjs/index.js
- /material-ui-nextjs-pages-router-ts-example/.next/standalone/.next/server/pages/_app.js
- /material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/require.js
- /material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/next-server.js
- /material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/next.js
- /material-ui-nextjs-pages-router-ts-example/.next/standalone/server.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at /material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/require-hook.js:54:36
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at mod.require (/material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/require-hook.js:64:28)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_cziuidd23tbj2wqeyxn2xirvka/node_modules/next-i18next/dist/commonjs/config/createConfig.js:35:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_cziuidd23tbj2wqeyxn2xirvka/node_modules/next-i18next/dist/commonjs/config/createConfig.js',
    '/material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_cziuidd23tbj2wqeyxn2xirvka/node_modules/next-i18next/dist/commonjs/appWithTranslation.js',
    '/material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_cziuidd23tbj2wqeyxn2xirvka/node_modules/next-i18next/dist/commonjs/index.js',
    '/material-ui-nextjs-pages-router-ts-example/.next/standalone/.next/server/pages/_app.js',
    '/material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/require.js',
    '/material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/next-server.js',
    '/material-ui-nextjs-pages-router-ts-example/.next/standalone/node_modules/.pnpm/[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/next.js',
    '/material-ui-nextjs-pages-router-ts-example/.next/standalone/server.js'
  ]
}

Expected behavior

Home page without an error should be opened

Your Environment

  • runtime version: node v18.18.0, pnpm v7.25.0 browser Google Chrome Version 117.0.5938.92
  • i18next version:
    "i18next": "23.5.1",
    "next": "13.5.4",
    "next-i18next": "14.0.3",
    "react-i18next": "13.2.2"
  • os: Mac
@adrai
Copy link
Member

adrai commented Oct 3, 2023

I'm not able to reproduce it:
image

@adrai
Copy link
Member

adrai commented Oct 3, 2023

And based on your error stacktrace, it's not related to next-i18next

@peakercope
Copy link
Author

And based on your error stacktrace, it's not related to next-i18next

Hello and thanks for the quick answer!
Do you think this issue should be opened in https://github.com/vercel/next.js repository?
Because without next-i18next everything works.

@adrai
Copy link
Member

adrai commented Oct 3, 2023

Like said, I'm not able to reproduce it, so it might be something in your local setup is wrong. Did you try to clone the repo in a fresh directory and try again? or on a different machine?

@peakercope
Copy link
Author

yes sure, I made a clean installation several times with pruned pnpm store.
The issue is reproduced every time for production run ("node .next/standalone/server.js") on both my local machine (AppleM1 / macos 13.6) and in docker container (node:18.17-alpine3.18).
pnpm dev works well

@adrai
Copy link
Member

adrai commented Oct 3, 2023

did you also try without pnpm, but with npm ?

@peakercope
Copy link
Author

tried it now
it works with npm

@adrai
Copy link
Member

adrai commented Oct 3, 2023

might be a pnpm issue?

@peakercope
Copy link
Author

It seems so.
Tried with [email protected] and [email protected] - the issue is reproduced for both.

@natterstefan
Copy link
Contributor

natterstefan commented Oct 3, 2023

+1, I have the same issue as I upgraded Next to 13.5.4 (Node 18, yarn).

I get the same error when I access the deployed app on Vercel.

Error: Cannot find module 'core-js/modules/es.array.map.js'
Require stack:
- /var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js
- /var/task/node_modules/next-i18next/dist/commonjs/appWithTranslation.js
- /var/task/node_modules/next-i18next/dist/commonjs/index.js
- /var/task/packages/web/.next/server/pages/_app.js
- /var/task/node_modules/next/dist/server/require.js
- /var/task/node_modules/next/dist/server/next-server.js
- /var/task/packages/web/___next_launcher.cjs
# ...

Edit: it does not happen on all pages using i18n, but on some. I may find out the difference between them and keep you posted.

@peakercope
Copy link
Author

peakercope commented Oct 3, 2023

yes, but issue seems is not related to next-i18next itself, it caused by how next.js standalone build collects node_modules
I've updated my example repo from the first message
To reproduce the issue:

or simply copy content of .next/standalone directory somewhere outside the project (e.g to /tmp) and run node server.js

@octavioamu
Copy link

same here I had to rollback to 13.5.3 seems a problem on next side but good to report here as took me a good day of work trying to figure out which package was failing.
The problem happens when using getServerSideProps and serverSideTranslations the pages with getStaticProps and serverSideTranslations works fine.

@meness
Copy link

meness commented Oct 4, 2023

Downgrading to [email protected] works. Here is the log:

-server.js',
    '/var/task/___next_launcher.cjs'
  ],
  page: '/collection/0x5a80497c8aba770421a8f6674c87182272e67e35'
}
Error: Cannot find module 'core-js/modules/es.array.map.js'
Require stack:
- /var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js
- /var/task/node_modules/next-i18next/dist/commonjs/appWithTranslation.js
- /var/task/node_modules/next-i18next/dist/commonjs/index.js
- /var/task/.next/server/pages/_app.js
- /var/task/node_modules/next/dist/server/require.js
- /var/task/node_modules/next/dist/server/next-server.js
- /var/task/___next_launcher.cjs
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at /var/task/node_modules/next/dist/server/require-hook.js:54:36
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Ze.e.<computed>._module.Module._load (/var/task/___vc/__launcher/__launcher.js:14:1964)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at mod.require (/var/task/node_modules/next/dist/server/require-hook.js:64:28)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:35:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js',
    '/var/task/node_modules/next-i18next/dist/commonjs/appWithTranslation.js',
    '/var/task/node_modules/next-i18next/dist/commonjs/index.js',
    '/var/task/.next/server/pages/_app.js',
    '/var/task/node_modules/next/dist/server/require.js',
    '/var/task/node_modules/next/dist/server/next-server.js',
    '/var/task/___next_launcher.cjs'
  ],
  page: '/collection/0x5a80497c8aba770421a8f6674c87182272e67e35'
}
Error: Cannot find module 'core-js/modules/es.array.map.js'
Require stack:
- /var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js
- /var/task/node_modules/next-i18next/dist/commonjs/appWithTranslation.js
- /var/task/node_modules/next-i18next/dist/commonjs/index.js
- /var/task/.next/server/pages/_app.js
- /var/task/node_modules/next/dist/server/require.js
- /var/task/node_modules/next/dist/server/next-server.js
- /var/task/___next_launcher.cjs
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at /var/task/node_modules/next/dist/server/require-hook.js:54:36
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Ze.e.<computed>._module.Module._load (/var/task/___vc/__launcher/__launcher.js:14:1964)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at mod.require (/var/task/node_modules/next/dist/server/require-hook.js:64:28)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:35:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js',
    '/var/task/node_modules/next-i18next/dist/commonjs/appWithTranslation.js',
    '/var/task/node_modules/next-i18next/dist/commonjs/index.js',
    '/var/task/.next/server/pages/_app.js',
    '/var/task/node_modules/next/dist/server/require.js',
    '/var/task/node_modules/next/dist/server/next-server.js',
    '/var/task/___next_launcher.cjs'
  ],
  page: '/collection/0x5a80497c8aba770421a8f6674c87182272e67e35'
}
Error: Runtime exited with error: exit status 1
Runtime.ExitError

@octavioamu
Copy link

octavioamu commented Oct 4, 2023

@meness
Remove node_modules folder and install again seems your code still using the latest nextjs version as you still have the error on the console

Eldemarkki added a commit to Eldemarkki/recipeamigo that referenced this issue Oct 5, 2023
@samtgarson
Copy link

Seems to be an upstream issue vercel/next.js#56357

@ajturpei
Copy link

ajturpei commented Oct 8, 2023

Same issue when deployed to Vercel. Using v13.5.4, npm and next-i18next

@fabianuribe
Copy link

Same issue after upgrading Next to 13.5.4 and deploying to Vercel (issue is not present in local environment). Downgrading to 13.5.3 fixes the deployment.

[email protected]/node_modules/next-i18next/dist/commonjs/config/createConfig.js',
    '/var/task/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next-i18next/dist/commonjs/appWithTranslation.js',
    '/var/task/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next-i18next/dist/commonjs/index.js',
    '/var/task/.next/server/pages/_app.js',
    '/var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require.js',
    '/var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/next-server.js',
    '/var/task/___next_launcher.cjs'
  ],
  page: '/'
}
Error: Cannot find module 'core-js/modules/es.array.map.js'
Require stack:
- /var/task/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next-i18next/dist/commonjs/config/createConfig.js
- /var/task/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next-i18next/dist/commonjs/appWithTranslation.js
- /var/task/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next-i18next/dist/commonjs/index.js
- /var/task/.next/server/pages/_app.js
- /var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require.js
- /var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/next-server.js
- /var/task/___next_launcher.cjs
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at /var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require-hook.js:54:36
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at e.<computed>._module.Module._load (/var/task/___vc/__launcher/__launcher.js:14:2079)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at mod.require (/var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require-hook.js:64:28)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (/var/task/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next-i18next/dist/commonjs/config/createConfig.js:35:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/var/task/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next-i18next/dist/commonjs/config/createConfig.js',
    '/var/task/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next-i18next/dist/commonjs/appWithTranslation.js',
    '/var/task/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/next-i18next/dist/commonjs/index.js',
    '/var/task/.next/server/pages/_app.js',
    '/var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/require.js',
    '/var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/server/next-server.js',
    '/var/task/___next_launcher.cjs'
  ],
  page: '/'
}
Error: Runtime exited without providing a reason
Runtime.ExitError

@timvandenhof
Copy link

I'm investigating the same issue, when running inside a docker container on Azure Web Apps. Seems not to be Vercel specific. Stacktrace is same as above it seems. Can share if needed.

@samuelloranger
Copy link

Same issue deploying on Railway with next standalone.
Here is the stacktrace:

Error: Cannot find module 'core-js/modules/es.array.map.js'

Require stack:

- /app/node_modules/next-i18next/dist/commonjs/config/createConfig.js

- /app/node_modules/next-i18next/dist/commonjs/appWithTranslation.js

- /app/node_modules/next-i18next/dist/commonjs/index.js

- /app/.next/server/pages/_app.js

- /app/node_modules/next/dist/server/require.js

- /app/node_modules/next/dist/server/next-server.js

- /app/node_modules/next/dist/server/next.js

- /app/server.js

at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1028:15)

at /app/node_modules/next/dist/server/require-hook.js:54:36

at Function.Module._load (node:internal/modules/cjs/loader:873:27)

at Module.require (node:internal/modules/cjs/loader:1100:19)

at Module.mod.require (/app/node_modules/next/dist/server/require-hook.js:64:28)

at require (node:internal/modules/cjs/helpers:119:18)

at Object.<anonymous> (/app/node_modules/next-i18next/dist/commonjs/config/createConfig.js:35:1)

at Module._compile (node:internal/modules/cjs/loader:1198:14)

at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)

at Module.load (node:internal/modules/cjs/loader:1076:32) {

code: 'MODULE_NOT_FOUND',

requireStack: [

'/app/node_modules/next-i18next/dist/commonjs/config/createConfig.js',

'/app/node_modules/next-i18next/dist/commonjs/appWithTranslation.js',

'/app/node_modules/next-i18next/dist/commonjs/index.js',

'/app/.next/server/pages/_app.js',

'/app/node_modules/next/dist/server/require.js',

'/app/node_modules/next/dist/server/next-server.js',

'/app/node_modules/next/dist/server/next.js',

'/app/server.js'

]

}

@zewas-digital
Copy link

Removing the '^' of the next-version worked for me.
before:
"next": "^13.5.3", "next-i18next": "^14.0.3", "i18next": "^23.5.1", "react-i18next": "^13.2.2"
after:
"next": "13.5.3", "next-i18next": "^14.0.3", "i18next": "^23.5.1", "react-i18next": "^13.2.2"

@denizgokce-facturee
Copy link

Removing the '^' of the next-version worked for me. before: "next": "^13.5.3", "next-i18next": "^14.0.3", "i18next": "^23.5.1", "react-i18next": "^13.2.2" after: "next": "13.5.3", "next-i18next": "^14.0.3", "i18next": "^23.5.1", "react-i18next": "^13.2.2"

This worked for me as well

@samtgarson
Copy link

It looks like this might have been fixed in the this PR which is available in 13.5.5-canary.8.

(For those “removing the ^”, know that you’re simply pinning next to 13.5.3—downgrading from 13.5.4 has already been highlighted as a workaround for this issue.)

@CopyJosh
Copy link

Though the Internal Server Error is resolved, some pages stop hydrating translations. Only happens sometimes, and not on dev. Context looks like it still has all the data, but useTranslation hook doesn't have any langs. Trying to debug further but just mentioning if anyone else hits a similar experience.

@meness
Copy link

meness commented Oct 16, 2023

Though the Internal Server Error is resolved, some pages stop hydrating translations. Only happens sometimes, and not on dev. Context looks like it still has all the data, but useTranslation hook doesn't have any langs. Trying to debug further but just mentioning if anyone else hits a similar experience.

Remove ns from next-i18next.config.js if it's defined.

@jbergstroem
Copy link

FWIW: Errors went away for me after updating to 13.5.5.

@adrai adrai closed this as completed Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests