Snyk Documentation

Snyk agent for Node.js

Snyk supports Node.js v8 and above.

Work with Runtime monitoring for Node.js as follows:

Installing the Snyk agent

    1. Add @snyk/nodejs-runtime-agent as a dependency to your project in order to start using Snyk Runtime Monitoring for your Node.js applications.
      Ensure the Require statement for the agent is entered prior to all other require statements that you may add to the code.

      //Example of Node.js code to run Snyk runtime agent
      require('@snyk/nodejs-runtime-agent')
      ({projectId: '0462e42b-c92f-4b48-bac8-81eb3ff7f43e',
      });
      
    2. Commit and push the changes to your manifest file (for example package.json).

    Upgrading the Snyk agent

    1. Run the following command from your project folder:npm install @snyk/nodejs-runtime-agent@latest
    2. Commit and push the changes to your manifest file (for example package.json).

    Disabling the Snyk agent

    Leave the agent installed for future use, while still disabling it for now:

    1. Set the enable parameter to false.
      Ensure this Require statement for the agent is entered prior to all other require statements that you may add to the code.
      //Example of Node.js code to disable Snyk runtime agent
      require('@snyk/nodejs-runtime-agent')
      ({ projectId: '0462e42b-c92f-4b48-bac8-81eb3ff7f43e', enable: false, });
    2. Commit and push the changes to your manifest file (for example package.json).

    Uninstalling the Snyk agent

    1. From the project CLI, remove the agent as a dependency to your project by running the following command:npm uninstall @snyk/nodejs-runtime-agent
    2. Remove the Require code snippet that you inserted at installation (and upgrade).
    3. Commit and push the changes to your manifest file (for example package.json).