Maaz Zindani

Loading the index…

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

react-slick builds, but the slick-carousel CSS import cannot be found

ErrorModule not found

Short answer

react-slick does not bring its stylesheets with it. They come from the separate slick-carousel package, so the CSS import fails when that package is not installed. The other causes are a wrong path inside the package, since the files sit in its slick folder, and a file name written with different casing, which breaks on case-sensitive Linux builds.

  • Applies to react-slick, slick-carousel 1.8, React 19
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check that the package is installed and look at the files inside it. Your import path has to match one of them exactly.

    npm ls slick-carousel
    ls node_modules/slick-carousel/slick
  2. 2Match what you see, then jump to its fix

    1. 1npm ls slick-carousel lists nothing, and the failing import names a path under slick-carouselslick-carousel is not installedFix
    2. 2slick-carousel is installed, yet the build still cannot find the file you importThe import path does not match a file in the packageFix
    3. 3The import works on your laptop but the same commit fails in a Linux CI jobThe file name differs in casing, so Linux builds fail while another machine passesFix

What does the error look like?

  • Module not found
  • The build stops on the line import "slick-carousel/slick/slick.css";

Cause 1 of 3

slick-carousel is not installed

1Check

The react-slick README installs the stylesheets with a second package, slick-carousel. A project that ran only npm install react-slick has the component but no CSS files.

ls node_modules/slick-carousel

2Fix

Install the package. If you cannot add it, the README also offers two stylesheet links to put in the page head instead.

npm install slick-carousel

<!-- alternative: in the HTML head -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.min.css" />

3Verify

The folder now lists slick.css and slick-theme.css, and the build gets past the import.

ls node_modules/slick-carousel/slick

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 3

The import path does not match a file in the package

1Check

The stylesheets live in the package's slick folder: slick.css is required and slick-theme.css is optional. A path such as slick-carousel/slick.css, without the slick folder, points at nothing.

grep -rn "slick-carousel" src

2Fix

Import the two files with their full paths, once, in a component or entry file that is always loaded.

import Slider from "react-slick";
import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";

3Verify

Start the dev server again; the carousel renders with its arrows and dots styled.

npm run dev

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 3 of 3

The file name differs in casing, so Linux builds fail while another machine passes

1Check

Next.js documents that wrong casing in an import breaks on case-sensitive environments such as most Linux-based CI, even if it passes locally.

ls node_modules/slick-carousel/slick
grep -rn "slick-carousel" src

2Fix

Write the file names exactly as the folder lists them: slick.css and slick-theme.css, all lower case.

import "slick-carousel/slick/slick.css";
import "slick-carousel/slick/slick-theme.css";

3Verify

Run the production build in a Linux environment, such as your CI job, and confirm it passes.

npm run build

Confirmed by nextjs.org

Did this fix it?

How do I stop it coming back?

  • Add slick-carousel to package.json in the same commit that adds react-slick, so a fresh install always has both.
  • Run the production build in CI on Linux, so a casing slip is caught before release.
  • Import the slick stylesheets in one place only, so there is a single line to check when a carousel loses its styles.

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.