Documentation

Check out our guides and API reference documentation on how to use Rollbar to monitor, debug, and triage errors.

Guides & SDKs    API Reference

Importing or Requiring Rollbar

Overview
JavaScript developers often working with Typescript, a variant of ECMAScript to help make their code more readable, efficient and maintainable. This guide is to help you understand how you can install Rollbar if you were to use either Typescript or ECMAScript (ES5, ES6, ES7, ES8, ES9).


Typescript

Typescript < version 3.6.0
If you are using a version of Typescript less than 3.6.0 you can import Rollbar using the following syntax.

import * as Rollbar from 'rollbar';

Typescript = version 3.6.x

For any version of Typescript in 3.6.x you need to make sure allowSyntheticDefaultImports or esModuleInterop is set in your Typescript options. Then you can import Rollbar using the following syntax.

import Rollbar from 'rollbar';

ECMAScript

For versions, ES6, ES7, ES8, and ES9 use the following code example to import Rollbar.

// ES6, ES7, ES8, ES9
import Rollbar from "rollbar";

If you are using ES5, import Rollbar using this sample code snippet.

// ES5
var Rollbar = require('rollbar');

Updated 5 months ago

Importing or Requiring Rollbar


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.