Next.js Discord

Discord Forum

require is not accepted in next.config.js but needed for sentry support

Answered
Short-tailed Albatross posted this in #help-forum
Open in Discord
Short-tailed AlbatrossOP
thats it. how to handle require in next.config.js
Answered by joulev
if you use next.config.mjs,
import { withSentryConfig } from "@sentry/nextjs";

if you use next.config.js
const { withSentryConfig } = require("@sentry/nextjs");

the file extension is important.
View full answer

3 Replies

@Short-tailed Albatross thats it. how to handle require in next.config.js
if you use next.config.mjs,
import { withSentryConfig } from "@sentry/nextjs";

if you use next.config.js
const { withSentryConfig } = require("@sentry/nextjs");

the file extension is important.
Answer
Short-tailed AlbatrossOP
yea i had toswitch to this and play around with the logic inside the file as well
thank you very much for responding