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

247
Views
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
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!