Skip to content

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

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

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 18, 2025
  2. chargome commented on Sep 18, 2025

    @chargome
    Member

    Hey @typeofweb thanks for reaching out! Looks like parts of the build-time code is executed during runtime which should not be the case. I'll try to ship a fix so we don't pull in chalk for now as this causes the error – also contacted Vercel on the underlying issue, we're investigating why this code gets pulled in.

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 18, 2025
  4. self-assigned this
    on Sep 18, 2025
  5. chargome commented on Sep 22, 2025

    @chargome
    Member

    @typeofweb could you actually provide a reproduction for this? I don't seem to run into this error.

  6. jmfmeireles commented on Sep 26, 2025

    @jmfmeireles

    Hi everyone,

    Do we have an estimated timeline for resolving this issue? I'm currently trying to upgrade chalk to its latest version in my project, but I'm blocked due to this problem.

    Thanks in advance for any updates!

  7. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 26, 2025
  8. 9 remaining items

  9. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 10, 2025
  10. Tthulasika commented on Oct 14, 2025

    @Tthulasika

    @chargome we are using webpack to run the app

  11. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Oct 14, 2025
  12. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 15, 2025
  13. Tthulasika commented on Oct 22, 2025

    @Tthulasika

    Hi @chargome, any update on this issue would be greatly appreciated. This is a blocker for what I'm working on and I will be going on vacation next week so would like to provide some context to my team member before I leave.

    Thanks in advance!

  14. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Oct 22, 2025
  15. chargome commented on Oct 23, 2025

    @chargome
    Member

    Hey @Tthulasika we're still investigating the underlying issue, I added a fix now that removes the chalk usage – hopefully this will unblock you guys for now. Will make sure to release it this week.

  16. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions