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.
Error: Can't find stylesheet to import.
╷
3 │ @use 'variables';
│ ^^^^^^^^^^^^^^^^^
╵
src/styles/main.scss 3:1 root stylesheetDiagnose 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.
# 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 buildCommon 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
- Confirm the partial exists with a leading underscore (
_variables.scss). - Make the import relative to the importing file, or add the directory.
- Match the case character for character.
// src/styles/main.scss
@use './abstracts/variables';
// resolves to src/styles/abstracts/_variables.scssDeclare load paths in the build
- Pass the directory holding your partials as a load path so bare imports resolve.
sass --load-path=src/styles src/styles/main.scss dist/main.cssMake the build reproducible before you debug it
- Pin the Node major in
setup-nodeand inengines. A bundler that resolves native bindings will pick a different prebuilt binary across majors. - Delete
node_moduleslocally and reinstall from the lockfile before concluding the runner is at fault; most "works locally" reports are stale local state. - Set
CI=truelocally 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-sizeor 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.