Skip to content

Unable to import rollbar module in TypeScript web application (Vue 3) #1148

Open
@MathBeaudoin

Description

@MathBeaudoin

I followed the documentation to integrate Rollbar into my web application.

After adding the Rollbar plugin to my Vue application, I am always given the following error (note that I am using ESNext):

Loading failed for the module with source “http://localhost:5173/node_modules/.vite/deps/rollbar.js?v=1d483b56”.

Steps taken

  1. (rollbar.ts) I have followed the TypeScript steps to import Rollbar and create the Rollbar instance:
import { App } from "vue";
import Rollbar from "rollbar";

const rollbar = new Rollbar({
    accessToken: 'myToken',
    captureUncaught: true,
    captureUnhandledRejections: true
});

export const RollbarPlugin =  {
    install(app: App) {
        app.config.errorHandler = (error: any, instance, info) => {
            console.log("error");
            rollbar.error(error, { vueComponent: instance, info });
        };

        app.provide('rollbar', rollbar);
    },
};
  1. (main.ts) I have correctly added the RollbarPlugin to my application:
import { RollbarPlugin } from "@/rollbar";

const app = createApp(App);
app.use(RollbarPlugin);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions