Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

215
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda