Can't Host MERN App on Render

My MERN app not detecting build dist folder

Build Command : npm build && cd ./server && npm i
Start Command : npm start

repo link : GitHub - The-Debuggerz/SMA: Social Media App

i tried multiple different build commands
but still same issue

Hi,

Your Build Command seems like it needs to be corrected. I’d expect to see something like:

npm install && npm run build && cd ./server && npm install

That’s assuming the “frontend” is in the root of the project, so:

  1. You’d need to install the frontend dependencies.
  2. Then you’re missing the run from npm script command.
  3. Then you move into your backend/server folder
  4. And finally install the backend dependencies.

There are various ways to deploy MERN apps, and how you implement yours is up to you, e.g.

  • Two Render services, one for the backend and one for the frontend.
    Commonly a Static Site for the frontend and a Web Service for the backend.

  • Alternatively, have your backend also serve the frontend files, so that it can run on a single Web Service - which it looks like you may have here.

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.