Vercel deployment error This Serverless Function has crashed. 500: INTERNAL_SERVER_ERROR

I have been trying to deploy my full mono repo with frontend and backend with nestjs on vercel and its been over three days I am not able to deploy me backend to the vercel.

every time I do it shows me this error message

and I did all kinds of things to resolve that error but nothing has worked so far for me.

this is my main.ts inside the src folder


import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ExpressAdapter } from '@nestjs/platform-express';
import * as express from 'express';

const server = express();

async function bootstrap() {
  const app = await NestFactory.create(AppModule, new ExpressAdapter(server));
  app.enableCors({
    origin: true,
    credentials: true,
  });

  await app.listen(process.env.PORT);
}
bootstrap();


and this is my vercel.json file inside my be-service


{
  "version": 2,
  "builds": [
    {
      "src": "dist/src/main.js",
      "use": "@vercel/node"
    }
  ],
  "routes": [
    {
      "src": "/(.*)",
      "dest": "dist/src/main.js",
      "methods": ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"],
      "headers": {
        "Access-Control-Allow-Origin": "*"
      },
      "status": 200
    }
  ]
}


and as you can see here I have the correct routes setup for my dist folder

and I am trying to build it on my local with this command

vercel dev

but still when I redirect to the local host with deployment it shows me that error which I attached at the top.


cies initialized +0ms
file:///.nvm/versions/node/v18.16.0/lib/node_modules/vercel/node_modules/@vercel/node/dist/dev-server.mjs:1073
    return listener(req, res);
           ^
TypeError: listener is not a function
    at Server.<anonymous> (file:///Users/milansachani/.nvm/versions/node/v18.16.0/lib/node_modules/vercel/node_modules/@vercel/node/dist/dev-server.mjs:1073:12)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)


please help me to resolve that if you have any ideas.

Hi, @milan-960!

Could you go through the troubleshooting steps outlined here?

Thank you!

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