Install the Node.js agent

Install the Node.js agent on your system.


Installing the Sqreen Node.js agent allows you to monitor the security of your application and block attacks in realtime. The installation process is the same as adding any new module:

Standard Node.js application

From a terminal, install the Sqreen module and save it into your project:

npm install --save sqreen

You must require the Sqreen Node.js module first at the top of your main script:


Why must the Sqreen module be required first?

If the Sqreen agent is not required as the first module at the top of your main script, the following applies:

  • Modules required before the Sqreen agent cannot be instrumented. For example, the database driver is not protected with Sqreen logic.
  • Request context lost: the agent might not be able to determine to which HTTP request the code relates to.
  • Protection on file access or command executions from Node.js core modules is not available.

To help you troubleshoot your setup, the agent informs you if it's not the first module included. It lists all the modules required before it. Please note that it does not detect and list Node.js core modules.

Then, from a terminal, set up your Sqreen token (provided from the user interface) in your home directory:

cat > sqreen.json <<EOF
  "app_name": "YOUR_APPLICATION_NAME",
  "token": "SQREEN_TOKEN"



Install the agent in a non-production environment


# Set the Sqreen token and the app name, including the environment
cat > sqreen.json <<EOF
app_name: "foobar (production)"

Basic configuration

The Sqreen agent stores your configuration in the sqreen.json file.



The Sqreen Node.js agent provides flexible configuration settings. Refer to Configuration for Node.js for more detailed information.

Uninstall the agent

To uninstall the Sqreen agent, remove the sqreen module from your application.


The Sqreen Node.js agent is available on npm.

Use different Sqreen applications for different environments

We recommend you to use different Sqreen applications on your different environments: production, staging and development.