MERN STACK deploy using app engine. Uncaught Syntax Error. Uncaught token '<'

hi Guys.

I have used both nodejs 16 & 18. whenever I try to deploy new version, I get error in my console "Uncaught SyntaxError:  unexpected Token '<' " and it shows the page as blank.

If I erase all history and cache OR hard refresh (CTRL + F5) ( 1 time process) after that it works fine as a normal website no need to do anything.

How I Deploy MERN App

  1. There are 2 folders (Frontend: Client, Backend: server)
  2. Run "NPM run build" Script for get production files
  3. Copy "build" folder from client to "Server" page (folder tree pics uploaded)

Nodejs main file (index.js) codes as below

const express = require('express');
const path = require('path');
const app = express();

app.use(express.static(path.join(__dirname, 'build')));

app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
})"Screenshot 2024-01-03 100918.pngScreenshot 2024-01-03 103741.png

ErrorLog and folder tree pics uploaded.

2 REPLIES 2

Hey, I am facing the same error. Have you resolved it?

Not yet

Top Labels in this Space