Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

212
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda