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

245
Visualizações
Unable to run the client code with html/JS and access nodeJS

I am new to nodeJs and I got the sample project below to start working on. I have a client folder which has index.html file and index.js and2 other .js files. From my html I have referred index.js

 <body style="margin: 0; padding: 10px;">
    <div id="app"></div>
    <script type="module" src="index.js"></script>
  </body>

And in my index.js I have

import { testApp } from "./testApp.js"

const appElement = document.getElementById('app')
const app = testApp()

app.attach(appElement)

In my server folder, I have server.js file and one file for apiService. If I run npm install and npm start, it shows my server is running. I can access the server api calls from browser. However I am not sure how to access this index.html page.

I am getting the below error if I use index.js in the client file as the main entry in package.json.

Uncaught ReferenceError: document is not defined

Can you please help on how to run this client html file and JS file, so that I can access this server calls from the html file.

about 4 years ago · Juan Pablo Isaza
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