Install Node.js agent using Contrast


If you are already using the Node.js agent, you should update the Contrast Node.js agent with npm since auto-update for the Node.js agent is no longer supported.

You must have Editor role permission to install an agent using Contrast.

  1. In the Contrast web application, select Add agent in the top right corner .

  2. Install the agent in your application's root directory. Add the agent to your node_modules folder without creating an entry in the dependencies list of your package.json file.

    npm install node-contrast-#.#.#.tgz

    Alternatively, if you use yarn, use this command to install the agent:

    yarn add file:/path/to/node-contrast-#.#.#.tgz
  3. Add the following script to your application's package.json:

    "scripts": {
        "contrast": "node-contrast <app-main>.js",
        "start": ...,
        "test": ...

    There will be a deprecation warning when running the Node.js agent as a runner. To run the agent as a preload module using the -r, --require option, use:

    "scripts": {
        "contrast": "node -r node_contrast/bootstrap <app-main>.js",
        "start": ...,
        "test": ...
  4. Configure the Node.js agent (you can download the contrast_security.yaml file from Contrast).

  5. Run the agent using:

    npm run contrast

    When you Configure the Node agent, you can change this npm script to include other runtime configurations, such as an alternate configuration file location.

  6. Exercise your application by performing either manual or automated testing to ensure your application is functioning correctly with the agent installed.

  7. Verify that your server is registered in Contrast and reports an instance of your application.