SSR React : Unexpected token ‘<' in call to renderToString()

I’m working on SSR with react but I’m encountering the following error. Syntax error: Unexpected token

const express = require("express");
const app = express();
const path = require("path");
const mongoose = require("mongoose");

const App =  require('../../../frontend/src/App');
const renderToString  = require('react-dom/server');

  const frontendPath = path.join(__dirname, '../../../frontend/src');
  app.use(express.static(frontendPath));
  
  app.get('*', (req, res) => {
    fs.readFile(path.resolve(frontendPath, 'index.html'), 'utf-8', (err, data) => {
      if (err) {
        console.error('Error reading index.html:', err);
        return res.status(500).send('An error occurred');
      }
  
      const renderedApp = ReactDOMServer.renderToString(<App />);
  
      return res.send(
        data.replace('<div id="root"></div>', `<div id="root">${renderedApp}</div>`)
      );
    });
  });

Is it something related to babel, please help.