Minimum project setup for Javascript SDK


I’m trying out the sentry/browser SDK with a fairly minimal project, and I’m hitting this error when calling Sentry.init:

Uncaught ReferenceError: exports is not defined
    at index.js:3

Where the offending line is

Object.defineProperty(exports, '__esModule', {
  value: true

from the file @sentry/browser/dist/index.js. Now my question is that what is the minimal project setup to get the SDK working? What does it expect to have?


Are you referencing @sentry/browser/dist/index.js in your html page?
If so, that is the problem, you should load @sentry/browser/build/bundle.js or
our CDN

The @sentry/browser/dist/index.js is meant to be used with a bundler.


That’s what I suspected. I’m not explicitly loading any file, just following the instructions in So my import was

import * as Sentry from '@sentry/browser';

I included the bundle.js from the main HTML file and that seems to work for now. Thanks! In the future, what’s the mechanism for importing since the bundle.js doesn’t seem to be a JS module?