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)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay