Cannot serve build directory: Uncaught SyntaxError: Unexpected token '<

Hello. Sorry for the lack of details. It was a bit late last night.

I have two server.js files. One for production and one for development.

The file structure:

image

The production file:

module.exports = ({ env }) => ({
  host: env("HOST", "0.0.0.0"),
  port: env.int("PORT", 1337),
  url: env("PROD_URL"),
  admin: {
    auth: {
      secret: env("ADMIN_JWT_SECRET", "some string"),
    },
    serveAdminPanel: false,
  },
});

The dev file:

module.exports = ({ env }) => ({
  host: "0.0.0.0",
  port: 1337,
  admin: {
    auth: {
      secret: env("ADMIN_JWT_SECRET", "some string"),
    },
    url: "/admin"
  },
});

I’m building the production build using NODE_ENV=production yarn build on Cloudflare Pages.

Here’s what happens if I test locally:

Build yarn start serve -s build
Production N/A (expected) :x:
Development :white_check_mark: :x: