Snippet of code :
let XMLHttpRequest = require('xhr2');
let xhr = new XMLHttpRequest();
xhr.open('GET', 'data.json', true);
xhr.send();
Issue : internal/modules/cjs/loader.js:969 throw err; ^
Error: Module 'xhr2' not found
I've tried installing it using : npm install xmlhttprequest However, the error persists.