Install APM Insight Node.js agent (versions 2.x and 3.x)

How to install the APM Insight Node.js agent (versions 2.x and 3.x)?

Warning
We highly recommend you download the latest version of the APM Insight Node.js agent. However, if you need to download agent versions v2.x or v3.x for some reason, kindly refer to the below given steps. 
1. Open your Node.js application.
2. Access the node packet manager (NPM).
3. Use the command npm i apminsight --save to install an APM Insight Node.js agent from NPM. This will create an APM Insight directory under node_modules.
4. Create a new file named apminsightnode.json and place it in the directory where you run the application. Add the below code snippet in the file. 
{
   "licenseKey" : "<license-key>",
   "appName" : "<application-name>",
   "port" : <application-port>
}
If you are using proxy:
{
   "licenseKey" : "<license-key>",
   "appName" : "<application-name>",
   "port" : <application-port>,
   "proxyServerHost" : "<proxy-server>",
   "proxyServerPort" : <proxy-port>,
   "proxyAuthUser" : "<proxy-user-name>",
   "proxyAuthPassword" : "<proxy-password>"
}
5. Follow any of the below:
  1. If you are using Common JS, follow the below instruction:
    Include the following code in the first line of your Node.js application start file before any other require statements.
      require('apminsight')()
    1. If you are using ES, follow the below instruction:
      Include the following code in the first line of your Node.js application start file before any other require statements.
        import apminsight from 'apminsight';
        apminsight.config()
    1. If you are using a typescript application, follow the below steps:
                    i. Create a file named apminsight.d.ts in the same directory as your application start file.
                    ii. Add the below line to the apminsight.d.ts file.
                         declare module "apminsight";
                    iii. Add the below lines to the first line of your application start file.
                          import * as apminsight from 'apminsight'; 
                          apminsight.config()
    6. Copy and paste the license key in the apminsightnode.json file.
    7. Restart your application and make few transactions to view data in APM Insight client. 

    If you are unable to add application port in the apminsightnode.json file, you can add it in your application start file as mentioned below. However other parameters like license key and app name should be added only in apminsightnode.json file. To add application port in application start file:
    require('apminsight')({
        port: <application-port>
    });
    

    Set configuration values as environment variables:

    You can set configuration values as environment variables using the following keys:
    1. License key - APMINSIGHT_LICENSE_KEY 
    2. Appname - APMINSIGHT_APP_NAME 
    3. Port - APMINSIGHT_APP_PORT
    4. proxyServerHost - APMINSIGHT_PROXYSERVER_HOST
    5. proxyServerPort - APMINSIGHT_PROXYSERVER_PORT
    6. proxyAuthUser - APMINSIGHT_PROXYAUTH_USER
    7. proxyAuthPassword - APMINSIGHT_PROXYAUTH_PASSWORD
    8. hostLicense - APMINSIGHT_HOSTLICENSE