Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Module not found: Can't resolve 'bootstrap/dist/css/bootstrap-theme.css'

ErrorModule not found: Can't resolve 'bootstrap/dist/css/bootstrap-theme.css'

Short answer

Bootstrap 4 removed the separate optional theme and replaced it with Sass variables. Current Bootstrap packages have no bootstrap-theme.css, so the import fails. Import bootstrap.min.css instead, and turn on the theme effects you need, such as gradients, in Sass.

  • Applies to Bootstrap 5.3, React 19, Webpack or Vite
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List what the installed Bootstrap package ships in dist/css, and see which version you have.

    npm ls bootstrap
    ls node_modules/bootstrap/dist/css | head
  2. 2Match what you see, then jump to its fix

    1. 1The file is missing from node_modules/bootstrap/dist/cssThe import comes from an old Bootstrap 3 tutorialFix
    2. 2The page looks flatter after removing the theme importYou still want the theme look (gradients)Fix

What does the error look like?

  • Module not found: Can't resolve 'bootstrap/dist/css/bootstrap-theme.css'
  • Import of bootstrap-theme.css copied from an older Bootstrap tutorial fails to compile

Cause 1 of 2

The import comes from an old Bootstrap 3 tutorial

1Check

Bootstrap 4's migration notes say the separate optional theme was replaced by configurable Sass variables. Bootstrap 5 documents bootstrap.min.css as its compiled stylesheet.

grep -rn "bootstrap-theme" src/

2Fix

Replace the import with the compiled stylesheet.

// src/index.js
import 'bootstrap/dist/css/bootstrap.min.css';

3Verify

The build compiles and the page uses Bootstrap styles.

npm start

Confirmed by getbootstrap.com

Did this fix it?

Cause 2 of 2

You still want the theme look (gradients)

1Check

The old theme is now a set of Sass options, for example $enable-gradients, set before Bootstrap's Sass is imported. The Bootstrap webpack guide imports its Sass as bootstrap/scss/bootstrap.

ls src/*.scss 2>/dev/null

2Fix

Install Sass, set the option before importing Bootstrap's Sass, and import your own stylesheet instead of the compiled one.

// src/custom.scss
$enable-gradients: true;
@import "bootstrap/scss/bootstrap";

3Verify

Buttons render with gradients.

npm install --save-dev sass && npm start

Confirmed by getbootstrap.com

Did this fix it?

How do I stop it coming back?

  • Match tutorial code to the Bootstrap version in package.json.
  • Check the package's dist/css folder before importing a file from it.
  • Prefer Sass variables to custom overrides for theme changes.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.