Amplify + React Build - Uncaught TypeError

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
2
3
4
5
// This throws error in production
Amplify.configure(options);

// This does not throw an error
Auth.configure(options);

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.

Share