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

250
Views
importing one java script file to another file error

I have 3 files one HTML, 2 javascript files named app.js and customer .js

I have an HTML page on which I have written this

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    hello
    <script src="app.js" type="module"></script>
</body>
</html>   

I just loaded app.js into this page

app.js contains this

import {person} from "./customer";
console.log("helllo");

and in customer.js i have this

const person={
    name:"hello"
}

export default person;

I am getting an import error the error shows

GET http://127.0.0.1:5500/customer net::ERR_ABORTED 404 (Not Found)

I am new to web development, please help me.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Here, the way you are importing it is wrong.

Let me explain. First of all, I can see that you are default exporting the module or whatever. In that case, you don't need those curly brackets.

import person from "./customer.js";

Second, just make sure that in your package.json you have "type" set to "module" just like this

"type": "module",

Third, if you are using VSCode, then you can right-click on your customer.js file and click on copy relative path to get its relative path from your project.

Summary:

  1. Correct your import statement
  2. Check if package.json is correct
  3. Copy relative path using VSCode

Hope this helps to solve your query!

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