Q:

ReferenceError navigator is not defined for FingerprintJS

I am trying to acquire browser fingerprint with the help of fingerprintjs2, an npm module in Javascript. But it gives me following error:-
ReferenceError: navigator is not defined

Logs:

Code:
const Fingerprint = require('fingerprintjs2');
const express = require('express');
const cors = require('cors');
const mysql = require('mysql');
const app = express();

const fpInstance = new Fingerprint();
fpInstance.get((result,err)=>{
    if(err){
        console.log('Error obtained',err)
    }
    else{
        console.log(result)
    } 
})

A:

I have found that fingerprintjs2 is a Javascript Library, doesn't work fine in Node.js. Luckily, a server-side version of the same has been released i.e, Fingerprint express middleware which is used for so called Passive fingerprinting.
Installation: npm install express-fingerprint
Usage:
var Fingerprint = require('express-fingerprint')

app.use(Fingerprint({
    parameters:[
        // Defaults
        Fingerprint.useragent,
        Fingerprint.acceptHeaders,
        Fingerprint.geoip,

        // Additional parameters
        function(next) {
            // ...do something...
            next(null,{
            'param1':'value1'
            })
        },
        function(next) {
            // ...do something...
            next(null,{
            'param2':'value2'
            })
        },
    ]
}))

app.get('*',function(req,res,next) {
    // Fingerprint object
    console.log(req.fingerprint)
})

