Skip to content

Module not found: ESM packages (supports-color) need to be imported. Use 'import' to reference the package instead. #16138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
kulterryan opened this issue Apr 26, 2025 · 1 comment

Comments

@kulterryan
Copy link

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

9.14.0

Framework Version

Next 14.2.6

Link to Sentry event

No response

Reproduction Example/SDK Setup

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

Sentry.init({
  tracesSampleRate: 1,
  debug: false,
});

Steps to Reproduce

I installed sentry using the wizard.

Expected Result

It should compile the code properly.

Actual Result

Getting error during compilation of instrumentation.ts file in nextjs.

./node_modules/.pnpm/[email protected][email protected]/node_modules/debug/src/node.js
Module not found: ESM packages (supports-color) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals

Import trace for requested module:
./node_modules/.pnpm/[email protected][email protected]/node_modules/debug/src/node.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/debug/src/index.js
./node_modules/.pnpm/[email protected][email protected]/node_modules/require-in-the-middle/index.js
./node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js
./node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@opentelemetry/instrumentation/build/esm/platform/node/index.js
./node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@opentelemetry/instrumentation/build/esm/platform/index.js
./node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@opentelemetry/instrumentation/build/esm/index.js
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@sentry/node/build/cjs/otel/instrument.js
./node_modules/.pnpm/@[email protected][email protected]/node_modules/@sentry/node/build/cjs/index.js
./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]._0955db245e18b83c766d7b3c2cf636ed/node_modules/@sentry/nextjs/build/cjs/index.server.js
./sentry.server.config.ts
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 26, 2025
@linear linear bot added the Bug label Apr 26, 2025
@chargome
Copy link
Member

chargome commented Apr 28, 2025

Hey @kulterryan thanks for reaching out.

Looks like debug is requiring supports-color, that's why you are running into https://nextjs.org/docs/messages/import-esm-externals (because it expects it to imported).

Seems not to be related to the Sentry SDK but I would try some of the following:

  • Reinstall your deps while clearing your pnpm cache
  • Try installing supports-color
  • experimental.esmExternals: 'loose' in your next.config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants