DEV Community

loading...

How Can I Set Up Absolute Imports in `jsconfig.json` for Create React App?

Manav Misra
I'm a JS Subject Matter Expert (SME) that has spent the past few years spearheading curricula and teaching initiatives at colleges and bootcamps, in person and virtually.
ใƒป1 min read

Given this setup Project directory structure

I am trying to do: import Loader from "base/Loader";

This is with Create React App, and there is a jsconfig.json like so:

{
  "compilerOptions": {
    "baseUrl": "src"
  },
  "include": ["src", "src/components"]
}

Still, the import fails. It only works if I say, import Loader from "components/base/Loader".

โ€ฆ

Discussion (0)