Source map support

If you use BabelJS, Typescript or any other Javascript superset you may have noticed that when an exception occurs, the stacktrace is not meaningful at all. To get interesting informations you need to generate source map files.

source map

Once these source map file are generated, PM2 will automatically detects them and will help you inspect errors.

Source map

Since the version 1.0.2, PM2 embbeds a mecanism to support javascript source map.

PM2 automatically detects javascript source map files if the file you start (let’s say app.js) has his equivalence (say app.js.map).

If you have a different layout, you can force the source map support by starting your application:

Via CLI:

$ pm2 start app.js --source-map-support

Or via JSON file:

{
  "apps" : [{
    "name"              : "my-app",
    "script"            : "script.js",
    "source_map_support": true
  }]
}

Inspect exceptions

Exceptions are logged into your application error log file.

To check your logs to detect exceptions type:

$ pm2 logs main

Else use https://keymetrics.io/ to have a clean listing and notifications about new alerts happening

Disable source map support

If you do not want PM2 to automatically support javascript source map you can use the option --disable-source-map.

It can be both used via CLI and via JSON file.