'Error building NextJS with @sentry/nextjs on AWS Amplify
I’m just trying to integrate sentry with NextjS v12 using @sentry/nextjs and sentry wizard, everything is fine on localhost and before integrating Sentry, but when I build the app on AWS Amplify, the build is error when starting SSR build with multiple error regarding Module not found: Can’t resolve ‘webpack’.
What is wrong with the build? Is there any solution for this? I have tried several options like adding target: ‘experimental-serverless-trace’ on next.config.js but no luck.
Appreciate your help!
Solution 1:[1]
Amplify doesn't support Nextjs 12 yet. You are going to have to use 11.1.4 You can find discussion on the GitHub issue here: https://github.com/aws-amplify/amplify-hosting/issues/2343
Can't say if your error is 100% the same but it looks like the "known issue" mentioned in that github issue.
Solution 2:[2]
I had a similar issue, which seemed to stem from missing webpack modules. I found the fix was to configure the Amplify environmental variable AMPLIFY_NEXTJS_EXPERIMENTAL_TRACE to true
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Leejjon |
| Solution 2 | Daniel Khlopotin |

