getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.98k stars 1.57k forks source link

[NUXT] Cannot use import statement outside a module #13916

Closed trezorsix closed 3 weeks ago

trezorsix commented 3 weeks ago

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nuxt

SDK Version

8.33.1

Framework Version

Nuxt 3.13.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

sentry.client.config.ts

Sentry.init({ // If set up, you can use your runtime config here // dsn: useRuntimeConfig().public.sentry.dsn, dsn: "https://417a6acdaa42cf95c2271c2fa14541d9@o4504802128101376.ingest.us.sentry.io/4508092319727616",

// We recommend adjusting this value in production, or using tracesSampler // for finer control tracesSampleRate: 1.0, });

sentry.server.config.ts

Sentry.init({ dsn: "https://417a6acdaa42cf95c2271c2fa14541d9@o4504802128101376.ingest.us.sentry.io/4508092319727616", });

Steps to Reproduce

  1. Initialize a fresh Nuxt.js project.
  2. Install the @sentry/nuxt package and add Sentry initialization (https://docs.sentry.io/platforms/javascript/guides/nuxt/).
  3. Attempt to start the project locally.

Expected Result

Project on the localhost have been successfully launched.

Actual Result

Getting the 500 error response from the localhost Nuxt instance running on the local host:

 ERROR  [nuxt] [request error] [unhandled] [500] Cannot use import statement outside a module
  at wrapSafe (node:internal/modules/cjs/loader:1469:18)
  at Module._compile (node:internal/modules/cjs/loader:1491:20)
  at Object..js (node:internal/modules/cjs/loader:1691:10)
  at Module.load (node:internal/modules/cjs/loader:1317:32)
  at Function._load (node:internal/modules/cjs/loader:1127:12)
  at TracingChannel.traceSync (node:diagnostics_channel:315:14)
  at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
  at Module.require (node:internal/modules/cjs/loader:1339:12)
  at require (node:internal/modules/helpers:125:16)
  at C:\dev\js\nuxt-sentry-test\node_modules\.pnpm\@opentelemetry+resources@1.26.0_@opentelemetry+api@1.9.0\node_modules\@opentelemetry\resources\build\esm\detectors\platform\node\machine-id\getMachineId.js:30:25
s1gr1d commented 3 weeks ago

linked for reference: https://github.com/getsentry/sentry-javascript/issues/13917