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

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

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