The habit of running the production build locally is the one that pays for itself repeatedly, well beyond this error.
Development and production differ in bundling, tree shaking, environment variables, runtime selection and error handling. A meaningful fraction of "works locally, breaks deployed" is really "works in development mode, breaks in production mode", and that has nothing to do with the deployment platform at all.
Building and starting locally takes a minute and turns a deploy-and-wait loop into an immediate one. Worth adding as a script so it is one command.