Skip to content

Express

Lightrun for Express

To use Lightrun with a Express application:

  1. In your project's folder, install the node agent by running npm install lightrun.

  2. Import Lightrun at the start of your application file (for example, app.js) by adding the following code:

    require('lightrun').start({
         company: '<YOUR_COMPANY_NAME>',
         lightrunSecret: '<YOUR_COMPANY_SECRET>',
    });
    
  3. Run the application as you normally would; for example, node index.js or npm start.

Getting Company Details

You can get <YOUR_COMPANY_NAME> and <YOUR_COMPANY_SECRET> by logging into the the Management Portal and looking inside the Download the Agent section.

Running the agent in TypeScript applications

Important

Lightrun for TypeScript requires sourcemap files to be included on the server where the production software is deployed.

Instructions

  1. Insert the following code at the start of your application file (for example, index.ts or app.ts).

    import * as lightrun from 'lightrun';
    
    lightrun.start({
        company: '<COMPANY-NAME>',
        lightrunSecret: '<COMPANY-SECRET>',
        filename: <full_path_to_metadata_file>
    });
    

    Info

    The filename parameter is optional. See here for details on constructing the metadata file.

  2. In the compilerOptions section of the tsconfig.json file, set the parameter "sourceMap" to "true".

  3. From a terminal, run the application.

    node index.js
    

Last update: May 18, 2022