How to Fix node-sass (and Migrate to sass) in CI
node-sass is deprecated and brittle in CI because it downloads a platform-specific binary at install time. The real fix is to stop using it.
node-sass (LibSass) fetches a prebuilt binary per Node version and platform; a mismatch or a failed download breaks the install. The pure-JS sass (Dart Sass) package is the maintained replacement.
Why it fails in CI
- No prebuilt binary for your Node version →
Node Sass does not yet support your current environment. - The binary download from GitHub releases times out or is rate-limited.
- A
node_modulescached on another Node version carries an incompatible binary.
Install it reliably
Migrate to sass (Dart Sass), which is pure JavaScript and needs no native binary. Its API is largely compatible for compilation.
Terminal
# replace node-sass with the maintained pure-JS package
npm uninstall node-sass
npm install --save-dev sass
# if you must keep node-sass, pin a version that supports your Node
# and ensure the binary download is not blocked/rate-limitedCache & speed
With sass, there is no binary to download - just normal npm caching. If you stay on node-sass, cache its binary directory keyed on Node version to avoid re-downloading.
.github/workflows/ci.yml
- uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}Common errors
Node Sass does not yet support your current environment→ Node/binary mismatch; migrate tosass.Missing binding .../binding.node→ the binary did not install; reinstall or migrate.- Download
ETIMEDOUT/403fetching the binary → transient/registry issue; migrate to remove the dependency.
Key takeaways
- node-sass is deprecated and downloads a fragile per-platform binary.
- Migrate to the pure-JS
sass(Dart Sass) package to remove the failure mode entirely. - Most build tooling supports
sassas a direct swap.
Related guides
How to Make node-gyp Builds Work in CIFix node-gyp build failures in CI: install Python and a C/C++ toolchain, and stop "gyp ERR! find Python" and…
npm Optional Dependency Skipped for Platform, Then Required at RuntimeFix npm installs where a platform-specific optional dependency is skipped in CI, then a build or runtime step…
Self-Healing CI: Auto-Retrying Transient Registry and 5xx FailuresRegistry timeouts, 429s, and 5xx errors are transient by definition. See why they happen and how self-healing…
Self-Healing CI: Missing System Packages and Setup GapsA missing system library or tool fails the build until someone installs it. See the manual fix and how self-h…