Reputation: 1
So I am using Derek Banas' Javascript tutorial and I'm getting this reference error.
Help??
document.addEventListener('DOMContentLoaded', SetupCanvas);
^
ReferenceError: document is not defined
at Object.<anonymous> (c:\Users\kjkta.DESKTOP-AVBUOR0\Repository\Tetris\TetrisBasic.js:33:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47```
Upvotes: 0
Views: 75
Reputation: 943999
That tutorial is intended for JavaScript running in a web browser, via an HTML document with a script element in it.
You are trying to run it with Node.js.
Node.js and browsers provide a different set of APIs on top of core JS. It is browsers that provide the document object (which represents the HTML document).
Upvotes: 1