Closed adamsh25 closed 1 year ago
Seems like pnpm adds to the dependenciesLayer.zip the dependencies with the version and yarn does not do this. I started a project from scratch using turbo: https://turbo.build/repo/docs/getting-started/create-new pnpm next.out:
yarn next.out
Hey!
So I took a look. The problem is with pnpm
itself not being really supported by Next's standalone output.
https://github.com/vercel/next.js/discussions/38435 https://stackoverflow.com/questions/70895922/pnpm-linking-with-standalone-nextjs-build https://github.com/vercel/next.js/discussions/40482
Overall it seems like a lot of fiddling to get it to work with breaking changes happening every half a year, from what I found.
I'm gonna do some more work on monorepos, but I don't plan to support pnpm
specifically in the near future. Feel free to share your findings, might get back to it later!
Issue: Cannot find next-sever.js in the main lambda Remarks: Works OK for yarn monorepo Stack:
{ "errorType": "Runtime.ImportModuleError", "errorMessage": "Error: Cannot find module 'next/dist/server/next-server'\nRequire stack:\n- /var/task/handler.js\n- /var/runtime/index.mjs", "stack": [ "Runtime.ImportModuleError: Error: Cannot find module 'next/dist/server/next-server'", "Require stack:", "- /var/task/handler.js", "- /var/runtime/index.mjs", " at _loadUserApp (file:///var/runtime/index.mjs:951:17)", " at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:976:21)", " at async start (file:///var/runtime/index.mjs:1137:23)", " at async file:///var/runtime/index.mjs:1143:1" ] }
Followed guids: _Monorepos In case you are using monorepo, there are few more requirements. Firstly, you need to setup outputFileTracing in your next.config.js see: https://github.com/vercel/next.js/issues/36386#issuecomment-1137665939.
Secondly, you need to setup hoistingLimits: workspace. We need node_modules to actually contain all the dependencies in order for NextJS to pick them up for standalone build.
Tested with Turbo@1.5.5 and Yarn@3.2.4_