Skip to content

Failed to load external module @sentry/nextjs: Error [ERR_REQUIRE_ESM] #17691

@typeofweb

Description

@typeofweb

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

10.12.0

Framework Version

15.6.0-canary.12

Link to Sentry event

No response

Reproduction Example/SDK Setup

// str/instrumenation.ts

import * as Sentry from "@sentry/nextjs";

export async function register() {
	if (process.env.NEXT_RUNTIME === "nodejs") {
		await import("../sentry.server.config");
	}

	if (process.env.NEXT_RUNTIME === "edge") {
		await import("../sentry.edge.config");
	}
}

export const onRequestError = Sentry.captureRequestError;

Steps to Reproduce

  1. Deploy the app on Vercel
  2. Open any page

Expected Result

No error.

Actual Result

Failed to prepare server Error: An error occurred while loading the instrumentation hook
    at ignore-listed frames {
  [cause]: Error: Failed to load external module @sentry/nextjs: Error [ERR_REQUIRE_ESM]: require() of ES Module /var/task/node_modules/chalk/source/index.js from /var/task/node_modules/@sentry/nextjs/build/cjs/config/turbopack/constructTurbopackConfig.js not supported.
  Instead change the require of index.js in /var/task/node_modules/@sentry/nextjs/build/cjs/config/turbopack/constructTurbopackConfig.js to a dynamic import() which is available in all CommonJS modules.

Additional Context

No response

Metadata

Metadata

Assignees

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions