Browser JS source maps

Using our source map library you can upload source maps to unminify stack traces and get human-readable method names, files, and line numbers.


@bugsnag/source-maps provides a CLI and a JavaScript library that can be used to upload your application’s source maps.

Install it globally on your system:

npm install --global @bugsnag/source-maps
# or
yarn global add @bugsnag/source-maps

Or locally inside your project:

npm install --save-dev @bugsnag/source-maps
# or
yarn add @bugsnag/source-maps


The library can be used via the command line:

bugsnag-source-maps upload-browser <opts>

Or as a JavaScript API:

const { browser } = require('@bugsnag/source-maps')

interface browser  {
  async function uploadOne (UploadSingleOpts): Promise<void>
  async function uploadMultiple (UploadMultipleOpts): Promise<void>


For a typical browser bundle, where your build generates a single minified file and accompanying source map:

bugsnag-source-maps upload-browser \
  --api-key YOUR_API_KEY_HERE \
  --app-version 1.2.3 \
  --bundle-url http://yourdomain.url/assets/example.min.js \
  --source-map path/to/ \
  --bundle path/to/example.min.js

If your build generates multiple assets (such as a Create React App build), you can supply the directory and the baseURL path. For example, if your output goes into build/static/js and that directory is served at http://yourdomain.url/static/js/*:

bugsnag-source-maps upload-browser \
  --api-key YOUR_API_KEY_HERE \
  --app-version 1.2.3 \
  --base-url http://yourdomain.url/static/js/ \
  --directory build/static/js

Option reference

The full set of options for @bugsnag/source-maps.

Property (CLI, JS API) Type Description
string your project’s API key [required]
string the version of the application you are building (this should match the appVersion configured in your notifier).
boolean detect the app version from the package.json file
string customize the endpoint for Bugsnag On-Premise
logger (JS only) Object provide a custom logger (must match the internal Logger interface)
boolean whether to replace existing source maps uploaded with the same version
string the top level directory of your project
(JS only)
RequestOptions supply options that should be passed to http.request(), for example if you need to provide an agent to send via a proxy.
(CLI only)
boolean less verbose logging
Single upload options
string the path to the source map [required]
string the URL the bundle is served at (may contain * wildcards) [required]
bundle string the path to the bundle
Multiple upload options
string the directory to start searching for source maps in, relative to the project root [required]
string the base URL that JS bundles are served from (may contain * wildcards) [required]