I'm currently working on developing a node package and in my JavaScript code, I have the following:
const calcHtml = './calc.html';
const xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4) {
if (this.status == 200) {
calcSelector.innerHTML = this.responseText;
}
if (this.status == 404) {
calcSelector.innerHTML = 'Page not found.';
}
}
};
xhttp.open('GET', calcHtml, true);
xhttp.send();
Everything works fine when running the script on a local project directory where it finds calc.html
However, when I
run npm install
on another project,
const calc = require('modal-calculator');
I encounter => GET http://localhost:8100/calc.html 404 (Not Found)
This error makes sense as calc.html is being searched in the current directory. So, how do I specify the path to use calc.html from node_modules\modal-calculator instead?