Home > Blockchain >  stuck at building process while hosting on Vercel
stuck at building process while hosting on Vercel

Time:06-03

I'm using node.js as a server-side to store the API respond, the app is working without any issue but recently I have been trying to host it on Vercel so I ran into many issue, the project get stuck at the building process...

the building output :

Building output

My server.js code :

// Setup empty JS object to act as endpoint for all routes
projectData = {};

// Require Express to run server and routes
const express = require('express');
// Start up an instance of app
const app = express();
/* Middleware*/
//Here we are configuring express to use body-parser as middle-ware.
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

// Cors for cross origin allowance
const Cors = require('cors');
app.use(Cors());
// Initialize the main project folder
app.use(express.static('website'));


// Setup Server
const port = 8000;
const Server = app.listen(port , run);

function run() {
    console.log(`hello there :D`);
    console.log(`here is ${port} ready to go`);
}
//GET method
app.get('/all', function(req,res){
    res.send(projectData)
    console.log(projectData);
})
//POST method
app.post("/addUserComment", function(req,res){
    projectData = {
        temp : req.body.temp,
        date : req.body.date,
        feeling : req.body.feeling,
    }
    console.log(projectData);
    res.send(projectData);
})

My working directory and build settings :

Working directory

Build settings

note: server.js is my server-side file, and my website folder includes my app.js file and my HTML, CSS files, also i did try to add Vercel.json file but i couldn't understand how to use it, so if you gonna add this file in your answer please explain how and why

CodePudding user response:

I think you need to remove the build command, because it's now trying to run the server.js file instead of making a build.

  • Related