Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!