Deploying NextJS project of a NX/monorepo

Hi there, I have an nx monorepo, I have 2 projects one of them is pure react/typescript and the other one NexJS/typescript. I was able to deploy successfully the react project as a “static site”, but I wasn’t able to deploy the nextjs project as a “web service”.

Can you please guide me?

next.config.js is not on the root directory. The project directory is in apps/nextjs-app.
The build is under dist/apps/nextjs-app
In order to CLI build I use: npx nx reset; npm install; npx nx build nextjs-app --prod
I’m able to build locally and I can confirm it’s located under dist/apps/nextjs-app

I was able to run it. I updated the distDir value in next.config.js. To be more specific the project is inside apps/nextJsProjectName, so when creating a web service in Render for a nextjs app I’m assuming Render is looking for .next folder in the root folder which is the default location for a standalone nextjs app.

  1. So I set the value of distDir → '../../.next'
  2. I added .nx/cache to the .gitignore file in the root folder
  3. In Render web service the Build Command I use is npx nx reset; npm install; npx nx build nextJsProjectName --prod
  4. In Render web service the Start Command I use is nx run nextJsProjectName:start

Aside bug: Now I’m facing another problem. When I use the api of NextJS and build the project I get this error: Type error: Cannot find name ‘Request’, which is very weird because that type comes from the Fetch API, and it should be included in @types/node 18.16.9.

Is @types/node in your devDependencies, or is a version earlier than 18.16.9 being installed?