Deploying backend to Vercel. API’s not working, getting a 500 internal server error. Vercel logs are as follows:
Starting the MongoMemoryServer Instance failed, enable debug log for more information. Error:
[Error: ENOENT: no such file or directory, mkdir '/home/sbx_user1051'] {
errno: -2,
code: 'ENOENT',
syscall: 'mkdir',
path: '/home/sbx_user1051'
}
You have officially fucked up!!
[Error: ENOENT: no such file or directory, mkdir '/home/sbx_user1051'] {
errno: -2,
code: 'ENOENT',
syscall: 'mkdir',
path: '/home/sbx_user1051'
}
No exports found in module "/var/task/api/index.js".
Did you forget to export a function or a server?
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.
INIT_REPORT Init Duration: 6270.48 ms Phase: init Status: error Error Type: Runtime.ExitError
Starting the MongoMemoryServer Instance failed, enable debug log for more information. Error:
[Error: ENOENT: no such file or directory, mkdir '/home/sbx_user1051'] {
errno: -2,
code: 'ENOENT',
syscall: 'mkdir',
path: '/home/sbx_user1051'
}
You have officially fucked up!!
[Error: ENOENT: no such file or directory, mkdir '/home/sbx_user1051'] {
errno: -2,
code: 'ENOENT',
syscall: 'mkdir',
path: '/home/sbx_user1051'
}
No exports found in module "/var/task/api/index.js".
Did you forget to export a function or a server?
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.
INIT_REPORT Init Duration: 7220.51 ms Phase: invoke Status: error Error Type: Runtime.ExitError
Unknown application error occurred
Have honestly no clue. Changed network access to everywhere on Mongo, tried to change port from 8080 to 5000, and tried to export default on index.js
env:
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.1.0",
"cors": "^2.8.5",
"express": "^4.18.2",
"jsonwebtoken": "^9.0.2",
"mailgen": "^2.0.27",
"mongodb": "^6.5.0",
"mongodb-memory-server": "^8.10.2",
"mongoose": "^6.8.0",
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"node": "^22.0.0",
"nodemailer": "^6.8.0",
"nodemon": "^3.0.3",
"otp-generator": "^4.0.0",
"vercel": "^34.1.3"
}
}
index.js:
import express from 'express';
import cors from 'cors';
import morgan from 'morgan';
import connect from './database/conn.js';
import router from './router/route.js';
const app = express();
/** middlewares */
app.use(express.json());
app.use(cors({
origin: '*',
}));
app.use(morgan('tiny'));
app.disable('x-powered-by');
const PORT = process.env.PORT || 5000;
/** HTTP GET Request */
app.get('/', (req, res) => {
res.status(201).json("Home GET Request");
});
/** api routes */
app.use('/api', router)
/** start server only when we have valid connection */
connect().then(() => {
try {
app.listen(PORT, () => {
console.log(`Server connected to http://localhost:${PORT}`);
})
} catch (error) {
console.log('Cannot connect to the server')
}
}).catch(error => {
console.log("You have officially messed up!!")
console.log(error);
})
I’m new to backend, so maybe I missed something I should’ve not missed.