server.mjs react vite app will not render react only index.html works fine locally

James Reilly 0 Reputation points
2025-08-01T10:57:47.6266667+00:00

running node 20 with vite and react

build works but when serving i am getting an error on my main.jsx file where it encounters the first jsx statement specifically

`return  (`
````    <div >`

the error message is **Uncaught SyntaxError: Unexpected token '<' (at main.jsx:20:5)**

package.json scripts are 

 `"type": "module",...`

`        "start": "node server.mjs",`

`        "build": "vite build",`

vite.config is

`import { defineConfig } from 'vite'`

`import react from '@vitejs/plugin-react'`

`// https://vite.dev/config/`

`export default defineConfig({  plugins: [react()],})`

github actions is

`name: Build and deploy Node.js app to Azure Web App - xxx`

`on:`

`  push:`

`    branches:`

`      - main`

`  workflow_dispatch:`

`jobs:`

`  build:`

`    runs-on: windows-latest`

`    permissions:`

`      contents: read #This is required for actions/checkout`

`    steps:`

`      - uses: actions/checkout@v4`

`      - name: Set up Node.js version`

`        uses: actions/setup-node@v3`

`        with:`

`          node-version: '20.x'`

`      - name:  npm install, build, and test`

`        run: |`

`           npm install`

`           npm run build --if-present`

`           npm run test --if-present`

`      `

`      - name: Upload artifact for deployment job`

`        uses: actions/upload-artifact@v4`

`        with:`

`          name: node-app`

`          path: .`

`  deploy:`

`    runs-on: ubuntu-latest`

`    needs: build`

`    `

`    steps:`

`      - name: Download artifact from build job`

`        uses: actions/download-artifact@v4`

`        with:`

`          name: node-app`

`      `

`      - name: 'Deploy to Azure Web App'`

`        uses: azure/webapps-deploy@v3`

`        id: deploy-to-webapp`

`        with:`

`          app-name: 'xxx'`

`          slot-name: 'Production'`

`          package: .`

`          publish-profile:`

will not render react code but it works locally just fine

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.