Skip to content
Latchkey

Sass "Can't find stylesheet to import" - Fix in CI

Dart Sass resolved an @use or @import and could not find the partial on disk. The path is wrong, the load path is not configured, or the filename case differs from the import on a case-sensitive runner.

What this error means

The compile aborts with Error: Can't find stylesheet to import. pointing at the @use/@import line. It fails the same way every run.

sass
Error: Can't find stylesheet to import.
  ╷
3 │ @use 'variables';
  │ ^^^^^^^^^^^^^^^^^
  ╵
  src/styles/main.scss 3:1  root stylesheet

Diagnose it: is it resolution, transform, or memory?

Bundler failures in CI fall into three families and the error text often points at the wrong one. A module that resolves on your machine and not on the runner is nearly always case sensitivity or a missing optional dependency; a transform error is a config or version mismatch; and an unexplained kill with no stack is the out-of-memory reaper, not a build error at all.

Terminal
# 1. resolution: does the file exist with EXACTLY that case?
git ls-files | grep -i "the/imported/path"

# 2. transform: what versions is CI actually resolving?
npm ls webpack vite rollup esbuild typescript 2>/dev/null | head -20

# 3. memory: was it killed rather than failed?
#    exit 137 = SIGKILL (OOM). Nothing in the bundler log will explain it.
node --max-old-space-size=4096 node_modules/.bin/vite build

Common causes

Wrong relative path to the partial

The import string does not point at the partial. Sass looks for _variables.scss next to the importing file; a wrong directory or a missing partial breaks it.

Load path not configured

A bare import like @use 'variables' relies on a configured load path (--load-path / includePaths). Locally it may resolve via editor config that CI does not replicate.

Case mismatch on Linux

Importing @use 'Variables' while the file is _variables.scss passes on macOS and fails on the case-sensitive Linux runner.

How to fix it

Verify the path and partial name

  1. Confirm the partial exists with a leading underscore (_variables.scss).
  2. Make the import relative to the importing file, or add the directory.
  3. Match the case character for character.
main.scss
// src/styles/main.scss
@use './abstracts/variables';
// resolves to src/styles/abstracts/_variables.scss

Declare load paths in the build

  1. Pass the directory holding your partials as a load path so bare imports resolve.
Terminal
sass --load-path=src/styles src/styles/main.scss dist/main.css

Make the build reproducible before you debug it

  • Pin the Node major in setup-node and in engines. A bundler that resolves native bindings will pick a different prebuilt binary across majors.
  • Delete node_modules locally and reinstall from the lockfile before concluding the runner is at fault; most "works locally" reports are stale local state.
  • Set CI=true locally to reproduce. Several toolchains change behaviour under it, including treating warnings as errors.
  • Exit code 137 is an out-of-memory kill. Raise --max-old-space-size or move to a larger runner rather than searching the bundler config.

How to prevent it

  • Prefer explicit relative paths (./ / ../) over bare imports.
  • Develop on a case-sensitive filesystem or add a CI case-check so casing bugs surface before the runner.

Frequently asked questions

What causes Sass "Can't find stylesheet to import"?
There are 3 common causes: wrong relative path to the partial, load path not configured, and case mismatch on linux. The import string does not point at the partial.
How do I fix Sass "Can't find stylesheet to import"?
There are 2 fixes depending on which cause you have: verify the path and partial name and declare load paths in the build. Work through them in order, since the first is the most common.
What does Sass "Can't find stylesheet to import" actually mean?
The compile aborts with Error: Can't find stylesheet to import.
How do I stop Sass "Can't find stylesheet to import" happening again?
Prefer explicit relative paths (./ / ../) over bare imports. The prevention section lists 2 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card