This is a minimal reproduction repo which demonstrates an issue where PNPM monorepos fail to deploy properly to Vercel when using prebuilt builds.
I believe this is an example case of:
- Clone this repo
- Change directories to the app foler with
cd app
- Setup new Vercel
- Run
vercel
. - Answer "Y" to "Set up and deploy..."
- Select whatever scope
- Select "N" for "Link to existing project?"
- Enter whatever app name
- Enter "./" for "In which directory is your code located?"
- Select "N" for "Want to modify these settings?"
- Once you hit the building step, you can cancel it and move on to the next step.
- Run
- Deploy the app to Vercel
vercel pull && vercel build && vercel deploy --prebuilt
Upon visiting the application, you should see a page with the text "Hello World".
Upon visiting the application, you will receive a 500 error
If you view the logs, you will see the following error:
2023-03-30T23:24:34.021Z undefined ERROR Cannot find module 'next/dist/server/next-server.js'
Require stack:
- /var/task/___next_launcher.cjs
2023-03-30T23:24:34.021Z undefined ERROR Did you forget to add it to "dependencies" in `package.json`?
RequestId: 7fc13ce8-5946-4ae4-97c4-223686ad2168 Error: Runtime exited with error: exit status 1
Runtime.ExitError
This issue does not exist when deploying this exact app using a non-prebuilt deploy. Try running the following in the app
directory:
vercel deploy
This deployment will succeed, and will not have the error described above.