Skip to content

Uncaught ReferenceError: require is not defined with Vue 3 #3091

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

Closed
6 of 7 tasks
karanagarwal17 opened this issue Dec 2, 2020 · 1 comment · Fixed by #3508
Closed
6 of 7 tasks

Uncaught ReferenceError: require is not defined with Vue 3 #3091

karanagarwal17 opened this issue Dec 2, 2020 · 1 comment · Fixed by #3508

Comments

@karanagarwal17
Copy link

Package + Version

  • @sentry/browser
  • @sentry/integrations
  • @sentry/tracing

Version:

5.28.0

Description

When doing one of the following:

import * as Sentry from '@sentry/browser'
import { Vue as VueIntegration } from '@sentry/integrations'
import { Integrations } from '@sentry/tracing'

I will get the following error in the browser:

Uncaught ReferenceError: require is not defined
    <anonymous> http://localhost:3000/@modules/@sentry/integrations.js:650

<anonymous> http://localhost:3000/@modules/@sentry/integrations.js:650
    InnerModuleEvaluation self-hosted:2346
    InnerModuleEvaluation self-hosted:2346
    evaluation self-hosted:2317

I believe this is due to using require on line 650 var localForage = require('localforage'); while the rest of the places are using import/export.

Is there something I am doing wrong?

@t-h-man
Copy link
Member

t-h-man commented Dec 18, 2020

Hi. After making sure that you have installed the latest Sentry Vue package as indicated here, use the code below as imports and SDK init and try again.

import Vue from "vue";
import * as Sentry from "@sentry/browser";
import { Integrations } from "@sentry/tracing";

Sentry.init({
  integrations: [
    new Integrations.BrowserTracing(),
  ],

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants