0

Whenever I try to access the document object in vs code I get ReferenceError: document is not defined. It seems the problem is code running in node.js which doesn't have the document thing.

My question is how do I set the vs code to run on the browser only, to be able to access DOM elements. I have installed Live server extension but the code still runs in node.js which gets me the error and I can`t properly check if the code is working the way I want. So please.. How do I solve this problem? How do I change the runtime environment in vs code?

mplungjan
  • 169,008
  • 28
  • 173
  • 236

1 Answers1

0

You don't need a server to do this.

Open the HTML file directly inside of the browser.

It will execute your scripts as Common JS.