Skip to content

[nuxt] Error in pnpm nuxt dev mode: Cannot use import statement outside a moduleΒ #13917

@TrezorTop

Description

@TrezorTop

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

Here is my configurations:

sentry.client.config.ts

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

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

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

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

Nuxt app on the localhost have been successfully launched.

Actual Result

Getting 500 response from the Nuxt server instance:

[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\@[email protected]_@[email protected]\node_modules\@opentelemetry\resources\build\esm\detectors\platform\node\machine-id\getMachineId.js:30:25

Metadata

Metadata

Assignees

Labels

BugPackage: nuxtIssues related to the Sentry Nuxt SDK

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions