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

391
Visualizações
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'models' imported from

I'm trying to configure my project to use absolute imports, so I have configured jsconfig.json as follows:

{
    "compilerOptions": {
       "baseUrl": "./src",
       "module": "commonjs",
       "target": "es2016"
    },
   "exclude": ["node_modules", "**/node_modules/*"]
}

My project structure looks like this:

enter image description here

but when I try to do an import like import { Account } from "models"; I get the following error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'models' imported from...

How can I solve this ?

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

0

The jsconfig.json file is used by VSCode's language server for static JavaScript analysis, it is not read by Node.js and therefore doesn't affect module loading in any way.

Options which come to mind are to use a transpiler, for example tsc, to transpile JS files (see this answer), or use native ESM support in Node.js possibly with custom loader. Mind that by default ESM imports expect full filename, including file extension (omitting file extensions in ESM is TypeScript specific quirk).

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