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

101
Visualizações
Node import statement can't recognize ../ prefix

I am trying to use the ES Module import with a path like ../module.js and it gives me this error:

node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 

Here is the structure of the folders:

.
├── module.js
├── index.js
├── folder
│   └── test.js

Also here is the import and export statements

//folder/test.js
import { test } from "../module"

//module.js
export async function test(data) {
    //Do Stuff then return data
}

Obviously, I have changed some file names and removed the function code. Please let me know if this is a problem.

Thank you!

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

In ECMAScript Modules, file extensions are mandatory according to the documentation, as well as directory indexes must be explicitly specified:

import { test } from "../module.js";
about 4 years ago · Juan Pablo Isaza Relatório

0

Try using require:

const { test } = require('../module.js')
about 4 years ago · Juan Pablo Isaza Relatório

0

module is already declared into nodejs, try changing the name of your file to something else.

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