Why wouldn't node.js recognize my index.html reference in the script.js file?
Pardon me for the dumb question but I couldn't find any fix and I've done copied perfectly a script from a YouTube tutorial and they seem to have no problem (neither do others, same method) but when I get to run node script.js in the terminal (or refreshing the html page in browser) nothing seems to work as it should and the html page remains static. I tried browsify and jsdom and what other suggested before in here but I wasted the same time with those too.
So here it is, even put it twice, once above </body> and once above </head>:
<script scr="script.js"defer></script>
...
<div class="countdown-days-c">
<p class="big-text"id="days">0</p>
<span>days</span>
</div>
And in the JS file like:
const daysElement = document.getElementById("days");
followed by this error
ReferenceError: document is not defined
at Object.<anonymous> (C:\Users\......\script.js:6:16)
at Module._compile...
and so on. Maybe I just missed something but I did exactly as shown and I've been struggling with this for some time now. I don't have any problem with the CSS file and the JS file can run perfectly standalone, but can't seem to work with the HTML.
You can't run the app in node because the global objects are different. What you should do is open the HTML file in the browser instead. That should solve all your problems.