Serverless functions crash (500) in prod (local OK). Module errors that don't make sense?
Unanswered
Spectacled Caiman posted this in #help-forum
Spectacled CaimanOP
Hi,
I'm running a Next 13 project (using
Local dev works as expected, as does deployment/CI.
But, my serverless functions have started returning 500, but the errors don't make sense:
On Next 13.2.4, I'm getting this in logs:
On latest Next 13, they still crash, but the error changed slightly:
If I install
Presumably connected to https://github.com/vercel/next.js/blame/0732f2f5383cb10bdba74bd17c61d0cc68e4c7f6/packages/next/src/server/require-hook.ts#L20C16-L28
I'm really confused on what could be causing this -- any pointers would be super appreciated 🙂
I'm running a Next 13 project (using
pages dir) on Vercel. It's a monorepo, being deployed via Turbo. Local dev works as expected, as does deployment/CI.
But, my serverless functions have started returning 500, but the errors don't make sense:
On Next 13.2.4, I'm getting this in logs:
2023-06-27T16:42:24.878Z undefined ERROR Cannot find module './initialize-require-hook'
Require stack:
- /var/task/node_modules/next/dist/server/next-server.js
- /var/task/supadewo/___next_launcher.cjs
2023-06-27T16:42:24.878Z undefined ERROR Did you forget to add it to "dependencies" in `package.json`?
RequestId: 7ded2e6b-0607-4497-ba36-bd629b2143be Error: Runtime exited with error: exit status 1
Runtime.ExitErrorOn latest Next 13, they still crash, but the error changed slightly:
Cannot find module 'styled-jsx/package.json'
Require stack:
- /var/task/supadewo/node_modules/next/dist/server/require-hook.js
- /var/task/supadewo/node_modules/next/dist/server/next-server.js
- /var/task/supadewo/___next_launcher.cjs
Did you forget to add it to "dependencies" in `package.json`?
RequestId: dd6c6bd9-14e5-4aca-bea3-8617aa5c1e8f Error: Runtime exited with error: exit status 1
Runtime.ExitErrorIf I install
styled-jsx, it started complaining about styled-jsx/style.Presumably connected to https://github.com/vercel/next.js/blame/0732f2f5383cb10bdba74bd17c61d0cc68e4c7f6/packages/next/src/server/require-hook.ts#L20C16-L28
I'm really confused on what could be causing this -- any pointers would be super appreciated 🙂
1 Reply
Spectacled CaimanOP
I think the issue relates to Turbo; When I override the build command on Vercel to just be "yarn build", I'm no longer seeing the (exact) issue above.