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

147
Visualizações
NextJS module resolution error with multiple paths in my path resolution

Hi everyone :) I was hoping I could get some fresh eyes on a problem I'm running into on my project:

I have a NextJS (12.1.4) project using absolute imports, I also have an NPM package where I directly import the source files in my project (since it's a library for shared components, internal use only). This package is called bs-components here.

Here is my jsconfig.json file

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@bscom/*": ["node_modules/@company/bs-components/*"],
      "*": ["node_modules/@company/bs-components/*", "*"]
    }
  }
}

I will explain the intent behind my paths config here:

The first entry for @bscom/* will allow me to import modules from my library using a shorthand.

The second entry for * is intended so that the module resolution goes like this:

  • Look in the component library first for a module, so that absolute imports in the component library are respected.
  • If module is not found in the library, then resolve using the baseUrl as the starting point for resolution.

Unfortunately when using this config, absolute imports within the component library fail with the following error:

./node_modules/@company/bs-components/styling/resets.js:1:0
Module not found: Can't resolve 'constants/colors'

This happens in my NextJS _document.js file, so during the server render step.

There are no modules with that path in my main project which could cause a conflict.

Any suggestions would be greatly appreciated, thanks :)

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