DEV Community

Manav Misra
Manav Misra

Posted on

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

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".

Top comments (0)

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API