Next.js Discord

Discord Forum

standalone build of an app from turbo workspace doesn't work standalone

Unanswered
African Slender-snouted Crocodil… posted this in #help-forum
Open in Discord
African Slender-snouted CrocodileOP
Hello, with this repo: https://github.com/saleor/apps
I can't get the build to run standalone. Trying to dockerize it, and don't want the final image to be 3 gigabytes with the whole workspace.
structure:
- apps
-- ...
-- avatax
---- package.json
- packages
-- .... some deps
- package.json

What I do:
- pnpm i
- pick an app, for example cd ./apps/avatax
- Add output: "standalone" to nextConfig inside apps/avatax/next.config.js
- pnpm i && pnpm run build
- node .next/standalone/apps/avatax/server.js works, so it built successfully
- copy apps/avatax/.next somewhere out of this workspace
- inside isolated folder, node .next/standalone/apps/avatax/server.js Errors, missing dependencies. I thought standalone meant it runs standalone?
error:
Error: Cannot find module 'next/dist/server/future/route-modules/pages/vendored/contexts/head-manager-context'
Require stack:
- /home/djkato/Documents/standalone/standalone/node_modules/.pnpm/next@14.1.0_@opentelemetry+api@1.7.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/client/script.js
...
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/djkato/Documents/standalone/standalone/node_modules/.pnpm/next@14.1.0_@opentelemetry+api@1.7.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/client/script.js',

7 Replies

African Slender-snouted CrocodileOP
Tried following this example too: https://turbo.build/repo/docs/handbook/deploying-with-docker#example
But it also fails at the same issue
African Slender-snouted CrocodileOP
It might have something to do with https://github.com/vercel/next.js/issues/48017
African Slender-snouted CrocodileOP
Lots of research later
It's def a bug
@African Slender-snouted Crocodile Lots of research later
Nice job troubleshooting your issue! 🙂

Being able to troubleshoot and research issues is what makes a good developer.
@Jboncz Nice job troubleshooting your issue! 🙂 Being able to troubleshoot and research issues is what makes a good developer.
African Slender-snouted CrocodileOP
I don't even use next js, I just want to build it...
Well, thanks. But no amount of research can get me a result in this case it seems.. do you by chance know how I could tree shake this?