Problems deploying Next.js site with Yarn Workspaces monorepo

I’ve seemed to fix this myself after much time spent. Posting for others that may be having trouble with this setup.

My project is a monorepo using Yarn workspaces. One of the packages is a Next.js based front end that I want deployed in Netlify. I created a new site via the Netlify UI with the following build settings:

Base directory: packages/my-next-ui
Build command: yarn build
Publish directory: packages/my-next-ui/.next

The deploy was successful. However when I go to the site none of the pages are loading (all 404s).

The problem is that the Next.js Runtime plugin is not being auto installed by the Build process. You can verify this by going to your Deploy Summary. It should look something like this:

If it does not say “Built using the Next.js Runtime” your site will not work.

I’m not exactly sure why the plugin is not installed with this setup (perhaps Support Engineers can chime in here) but you need to install the plugin manually:

  1. install the plugin as a dev dependency under the next package

yarn add @netlify/plugin-nextjs -D

  1. configure the plugin in netlify.toml
[[plugins]]
  package = "@netlify/plugin-nextjs"

Check in and redeploy. Verify that thee Next.js Runtime is installed (see pic above).

Hope this saves folks some time!

Hey there, @djghokie75 :wave:

Thank you so much for taking the time to write this up and share this. It will definitely be beneficial to future forums members who encounter this obstacle, so we really appreciate you sharing!

Happy building :rocket: