How to use CryptoJS package in Postman Flows Evaluate block

How can we use evaluate block in postman flows to validate the hmac signed payload. I’m using the below code

const crypto = require('crypto'); 
const secret = 'mySecretKey'; 
const payload = request.body; 
console.log(payload);
const receivedHmac = payload;
const data = JSON.stringify(payload); 
const generatedHmac = crypto.createHmac('sha256', secret).update(data).digest('hex');
if (receivedHmac === generatedHmac) { 
    console.log('Payload is valid'); 
    } else {
         console.log('Payload is not valid'); 
    }

This is throwing me an error invalid redefinition of global identifier.