Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.2K
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!