Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
Trying to run hello world JavaScript program on visual studio but keep getting 'document' is undefined

Error that I am getting and my simple code

I've watched videos and when people run this it works just fine. I also tried console.log and I get-- 'console' undefined. I have node.js installed

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

document is not a built-in part of JavaScript. It is part of the Web API provided by browsers which you get when you load your JS by using a <script> element in an HTML document in a web browser. You aren't doing that, and document doesn't have a log method anyway.

You're running your JS using Windows Script Host, which isn't that. WSH does not have a document.

You probably want either:

  • the WriteLine method
  • to not use WSH (Browsers and Node.js being more common ways to run JS)
about 4 years ago · Juan Pablo Isaza Report

0

You aren't running in a browser, there is no document (plus, it'd be console.log there too). You are running in Windows Script Host, you can use WScript.Echo instead. But I'd rather recommend you to run your code in a browser or node.js anyway, WSH isn't a very useful environment for learning modern JavaScript.

You wrote you have node.js installed, so the issue could be that you simply used the wrong command: it should be node and not start!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!