Deploying website to vercel only returns index.js code

Hello I realize that there have been a few threads about my issue already but when i deploy my webapp to vercel i only see the index.js file in my dist folder. I followed the express guide as best I could and changed my vercel.json file to point the destination towards the server folder which is where i keep index.ts.

I also adjusted my dev command to be vite --port 5000 to match the port i have chosen in my server/index.ts file. when i run vercel dev and npm dev locally, i am able to navigate to the local host and interact with my website. Is there something i should change with vercel.json to fix the deployment? Thanks again for your help!

my repo can be found here:
https://github.com/Synaptrix-Labs/Website

If you’re having trouble deploying an Express app, this guide can help.

You can also ask v0 for suggestions tailored to your own project setup.

Hi @eric-synaptrix-la, welcome to the Vercel Community!

The GitHub repo seems to be private, so we can’t access it.

In the meantime, I’d recommend reading through the following post:

Hi Anshuman,

Thanks for your reply, I’ve changed the repo visibility so you should be able to view it now. I will also take a look at this link, thanks again!

Hello,
i’ve managed to deploy the website after moving my index.ts file to a folder called api located in the root of my directory. However, I am getting an error that the packaged version of index.ts, index.js, is unable to import the other .ts files that I need.

Error [ERR_MODULE_NOT_FOUND]: Cannot find module ‘/var/task/server/routes’ imported from /var/task/api/index.js
at finalizeResolution (node:internal/modules/esm/resolve:269:11)
at moduleResolve (node:internal/modules/esm/resolve:937:10)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:1173:14)
at defaultResolve (node:internal/modules/esm/resolve:1216:79)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:542:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)
at ModuleWrap. (node:internal/modules/esm/module_job:96:40)
at link (node:internal/modules/esm/module_job:95:36) {
code: ‘ERR_MODULE_NOT_FOUND’,
url: ‘file:///var/task/server/routes’
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.
Error [ERR_MODULE_NOT_FOUND]: Cannot find module ‘/var/task/server/routes’ imported from /var/task/api/index.js
at finalizeResolution (node:internal/modules/esm/resolve:269:11)
at moduleResolve (node:internal/modules/esm/resolve:937:10)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:1173:14)
at defaultResolve (node:internal/modules/esm/resolve:1216:79)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:542:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)
at ModuleWrap. (node:internal/modules/esm/module_job:96:40)
at link (node:internal/modules/esm/module_job:95:36) {
code: ‘ERR_MODULE_NOT_FOUND’,
url: ‘file:///var/task/server/routes’
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.

Those are stored in a folder called server in the root of the directory, and I’ve tried to include it in my vercel.json:
{
“version”: 2,
“functions”: {
“api/index.ts”: {
“includeFiles”: “server/**/"
}
},
“rewrites”: [
{
“source”: "/api/(.
)”,
“destination”: “/api/index.js”
},
{
“source”: “/(.*)”,
“destination”: “/public/index.html”
}
]
}

my build command in package.json is:
“build”: “vite build && esbuild api/index.ts --platform=node --external:lightningcss --bundle --format=esm --outfile=dist/api/index.js”,

can you help me resolve this error?