Skip to content
Latchkey

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

Sass could not resolve a @use/@import/@forward target. The path is wrong, the case differs from the file, or the directory it lives in is not on Sass's load path.

What this error means

The compile fails with Error: Can't find stylesheet to import. pointing at the @use/@import line. It is deterministic and names the importing file and column.

sass output
Error: Can't find stylesheet to import.
  ╷
2 │ @use 'variables';
  │ ^^^^^^^^^^^^^^^^^
  ╵
  src/styles/main.scss 2: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 path or case mismatch

The partial does not exist at that path, or its casing differs (Variables vs variables). Case-sensitive Linux CI fails where macOS resolved it.

Directory not on the load path

A @use 'variables' that relies on a configured loadPaths/includePaths (e.g. a shared styles/ root) fails when the build does not pass that load path.

How to fix it

Correct the path and case

Sass partials are named with a leading underscore but imported without it - confirm the file exists with matching case.

Terminal
ls -la src/styles/_variables.scss   # imported as @use 'variables'
# fix the @use path or rename to match the case

Configure the load path

Tell your bundler's Sass integration where to find shared partials.

vite.config.ts
// vite.config.ts
export default defineConfig({
  css: { preprocessorOptions: { scss: { loadPaths: ['src/styles'] } } },
})

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

  • Match @use/@import paths and casing to the real partial files.
  • Configure loadPaths/includePaths for shared style roots.
  • Compile styles in CI so resolution gaps fail before deploy.

Frequently asked questions

What causes Sass "Can't find stylesheet to import"?
There are 2 common causes: wrong path or case mismatch and directory not on the load path. The partial does not exist at that path, or its casing differs (Variables vs variables).
How do I fix Sass "Can't find stylesheet to import"?
There are 2 fixes depending on which cause you have: correct the path and case and configure the load path. 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 fails with Error: Can't find stylesheet to import.
How do I stop Sass "Can't find stylesheet to import" happening again?
Match @use/@import paths and casing to the real partial files. The prevention section lists 3 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