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

379
Visualizações
Imports from public folder Nextjs in typescript give error: Cannot find module

I am trying to import files using regular import and with the custom absolute paths in Nextjs using typescript. For some reason I keep getting an error that the module cannot be found but my IDE is able to link the file when I click on it. Also, when its a regular javascript file, instead of typescript, it works fine and files are imported.

For now im using // @ts-ignore and it works, but I wonder if there is a better way to solve this error.

My tsconfig:

    {
  "compilerOptions": {
    "target": "es2015",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/components/*"],
      "#/*": ["public/assets/images/*"],
    }
  },
  "include": [
    "public/**/*",
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try changing the path of the import.

If you have a baseUrl of “.”, the path would be ...from '/public/...'. instead of ...from './public/...'

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