Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.2K
Vistas
How to Build Production Next.js with Custom Server (Nest.js)

I need help on how should I do compile/build my project using Next.js when I use a custom server.

I actually use Nest.js (TypeScript Node.js Framework) as my Backend and wrap my Next.js inside it (since Nest.js is node based so I think this should work) and it actually working.

This is one of the tutorial that I followed: https://javascript.plainenglish.io/render-next-js-with-nestjs-did-i-just-made-next-js-better-aa294d8d2c67.

And when I tried to build production, Next.js give me error like this

problem

So basically, when I use nest build command, it successfully compiled but only the backend part (which is Nest.js). Whenever I tried to run into localhost, it would error and said the same thing above.

And the same as the second command (which is I tried to add next build command), it would show the same error.

I know where is the problem is (they basically need the compiled .next/ folder) but kinda confused how to solve this. Do you have any idea on how I should tell the compiler that the pages/ folder has been moved into src/client/pages?

[EDIT] Just for your information, this is my folder architecture.

Folder Structure


Any kind of ideas would be a really help. Thanks guys!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I just fixed my own issue right after several minutes I post this even I've struggle for like hours!

So, just want to let you guys know if anyone ever comes with the same issue. Somehow, my solution is comes because this Next.js CLI docs, so thanks to that.

What I did is just simply change the directory first into the right Next.js folder's code and start compile it. I did it from package.json build scripts.

"scripts": {
    "build": "NODE_ENV=production nest build && NODE_ENV=production cd src/client && next build"
    ...
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda