Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
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 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda