Install Node.js agent manually
To install or update the agent manually:
Install the latest version of the agent from npm by running this command from the application's root directory:
npm install @contrast/agent
Alternatively, if you use yarn, run this command to install the agent:
yarn add @contrast/agent
Note
If you don't want to install optional dependencies included with the Node.js agent, append the
--no-optional
CLI flag to your install command or addoptional=false
to your NPMRC file.Set authentication keys with environment variables. Make sure your Node.js application has access to the environment variables at runtime.
Alternatively, set the configuration with YAML configuration using this template. Make sure the
contrast_security.yaml
is in the applications root directory.Add this command to the scripts section of your application's package.json file:
"scripts": { "contrast": "node -r @contrast/agent <app-main>.js", "start": ..., "test": ... }
Run your application with the agent:
npm run contrast
Tip
You can change this npm script to include, other runtime configurations such as an alternate configuration file location.
Exercise your application by performing either manual or automated testing to ensure your application is functioning correctly with the agent installed.
Verify that your server is registered in Contrast and reports an instance of your application.