Node.js document is not defined
document
relates to the DOM (Document Object Model) in a web browser.
Node.js, however, is not a browser environment. It is a server environment, much like PHP or Perl, and as such, you can’t access the browser’s DOM or do anything specific to browser-hosted JavaScript.
The closest you could get is using something like browserify to include Node.js modules in your client-side code.
ReferenceError: document is not defined (JavaScript in VS Code)
In your screenshot, you're attempting to run the script using Node.js (the server-side JavaScript executable).
Since you say you're running live-server, you should be looking at your browser instead, not trying to run your code via Node.
Related Topics
Create a Newline for Every X Number of Characters
How to Retrieve Value in Input Checkbox (Using Reactjs)
How to Detect Overflow of React Component Without Reactdom
Merge Two Json/Javascript Arrays in to One Array
Extract Part of Url With Regex
How to Add Spaces to for Loop Output in JavaScript
How to Send a Http Delete Request from Browser
New Line in Paragraph When Enter Is Pressed in Textarea
How to Increment a Number After Every 1 Second Using JavaScript
Regexp to Match Every Occurence After N Occurences
How to Prevent Drag on a Child, But Allow Drag on the Parent
Generate a Weighted Random Number
How to Push Value Pair into Object Using Method
How to Call the Same Method for Different Elements With Different Ids