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

248
Vistas
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 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