Skip to content

[nuxt] Error when using setUser in @sentry/nuxt: Cannot use import statement outside a module #14221

@sumomo015

Description

@sumomo015

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.37.1

Framework Version

3.14.159

Link to Sentry event

https://tenri.sentry.io/issues/6057040304/events/119f2704c7c7455bbc09c01784e89105/

Reproduction Example/SDK Setup

https://github.com/sumomo015/nuxt-sentry-setuser

Steps to Reproduce

Reproduction Environment

  • node v20.18.0
  • pnpm 9.12.3
  • development environment (no error in the build environment)

using setUser
https://github.com/sumomo015/nuxt-sentry-setuser/blob/main/app.vue#L4

<script setup lang="ts">
import * as Sentry from '@sentry/nuxt'

Sentry.setUser({ id: 'nuxt' })
</script>

Steps to Reproduce

1. Install dependencies
pnpm install
2. Start nuxt
pnpm run dev
3. Open your browser and navigate to
http://localhost:3000/
4. You will see the following error
[nuxt] [request error] [unhandled] [500] Cannot use import statement outside a module

Expected Result

Nuxt app on the localhost have been successfully launched.

Actual Result

Image

Image

Metadata

Metadata

Assignees

Labels

BugPackage: nuxtIssues related to the Sentry Nuxt SDKdocs-ignoreDo not include content in documentation AI training

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions