My AWS Amplify + React app throws an Uncaught TypeError
when running the production build, but works just fine with react-scripts start
.
Error in Chrome:
Uncaught TypeError: Cannot read property 'call' of undefined
Error in FireFox:
Uncaught TypeError: e[t] is undefined
After TOO much troubleshooting, I finally found the error. For some reason calling the main configure function would blow up in production but not dev - I assume some component got trimmed out by Webpack. I am only using the Auth
module of the Amplify SDK, so this solution works for me.
1 | // This throws error in production |
Conclusion
Somehow I managed to bump into this error twice a few months apart, and could not recall what I did to solve it the first time. Hopefully, this saves you (and me) some troubleshooting time in the future.