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

225
Visualizações
Absolute imports using alias not working in ubuntu. Works in windows

So I'm using an absolute import statement in react and it works well in Windows system. When same project is started in Ubuntu, I get

Can't resolve './components/base/navBar/NavBar' in '/home/<user_name>/Files/Projects/<project_name>/src'

Below is the babel plugin config (.babelrc),

[
    "babel-plugin-root-import",
    {
        "paths": [
            {
                "rootPathPrefix": "~",
                "rootPathSuffix": "./"
            },
            {
                "rootPathPrefix": "@src",
                "rootPathSuffix": "src"
            },
            {
                "rootPathPrefix": "@Component",
                "rootPathSuffix": "src/components"
            }
        ]
    }
]

and this is the import statement I'm using in ./src/App.js

import Navbar from "@Component/base/navBar/NavBar";


and this is the rule for js file in webpack,

{
    test: /\.js$/,
    exclude: /node_modules/,
    use: {
        loader: "babel-loader",
        options: {
            presets: ["@babel/preset-env", "@babel/preset-react"],
        },
    },
}

Works in windows. Does not work in ubuntu. What am I doing wrong here?

Thanks for your time.

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

0

Try this. Describes well how to use absolute imports in React.

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