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.
Error: Can't find stylesheet to import.
╷
2 │ @use 'variables';
│ ^^^^^^^^^^^^^^^^^
╵
src/styles/main.scss 2: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 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.
ls -la src/styles/_variables.scss # imported as @use 'variables'
# fix the @use path or rename to match the caseConfigure the load path
Tell your bundler's Sass integration where to find shared partials.
// 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-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
- Match
@use/@importpaths and casing to the real partial files. - Configure
loadPaths/includePathsfor shared style roots. - Compile styles in CI so resolution gaps fail before deploy.