Registry / web-framework / express-dart-sass

express-dart-sass

JSON →
library1.0.4jsnpmunverified

Express middleware for dart-sass (the primary Sass implementation, now deprecated in favor of the new JS API). Version 1.0.4 is the latest stable release (last updated in 2021). It recompiles .scss/.sass files automatically for Express-based HTTP servers. Key differentiators: uses dart-sass (which is faster and more feature-complete than node-sass), supports legacy options like outputStyle, prefix, and error handling. The package is in maintenance mode due to the deprecation of the legacy JS API (LibSass/Node Sass) and the move to the new embedded dart-sass API.

npm install express-dart-sass
INSTALL
IMPORT
SIG · EXPRESS-DART-SASS
E
express-dart-sass
web-frameworkjavascriptv1.0.4
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ const sassMiddleware = require('express-dart-sass');
✗ import sassMiddleware from 'express-dart-sass';
This package is CommonJS only; it does not provide ESM exports. Use require().
default (ESM style)
✓ import sassMiddleware from 'express-dart-sass'; // Works only if your project is configured for ESM interop.
✗ import { sass } from 'express-dart-sass';
The package's module field points to an ESM wrapper? Actually it's CJS; some bundlers allow default import. Named import does not exist.
Options interface
✓ // No type exports; define your own interface based on docs
✗ import { Options } from 'express-dart-sass';
The package does not ship TypeScript declarations. Use @types/express-dart-sass? There are none.

Sets up express-dart-sass middleware to compile SCSS files from src to dest with compressed output, then serves static files.

const express = require('express'); const sassMiddleware = require('express-dart-sass'); const path = require('path'); const app = express(); app.use(sassMiddleware({ src: __dirname, dest: path.join(__dirname, 'public'), debug: true, outputStyle: 'compressed', prefix: '/prefix' })); app.use(express.static(path.join(__dirname, 'public'))); app.listen(3000, () => console.log('Server running on port 3000'));
Debug
Known issues
deprecatedThe dart-sass legacy JS API (used by this middleware) is deprecated in favor of the new compile() API.
fix
Consider migrating to sass (dart-sass) direct integration or use the new compile API in your own middleware.
affects: >=1.0.0
gotchaMiddleware must be placed before express.static to serve compiled CSS.
fix
Ensure app.use(sassMiddleware(...)) precedes app.use(express.static(...)).
affects: all
gotchaThe 'dest' option is required; if omitted, compiled files may overwrite source .scss files (since default is src).
fix
Always specify dest or use response: true if you don't need file output.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'sass'
The package depends on dart-sass (the `sass` npm package) which is not installed.
fix
npm install sass --save
TypeError: sassMiddleware is not a function
CommonJS require returns an object with a default property when using ESM-style import in a CJS environment? Actually, the package exports a function directly, but if you use `import sassMiddleware from 'express-dart-sass'` in a TypeScript project with esModuleInterop: false, it may cause issues.
fix
Use `const sassMiddleware = require('express-dart-sass')` or enable esModuleInterop in tsconfig.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
expressrequiredThe middleware is designed to work with Express; it uses Express-style request/response objects.
sassrequireddart-sass (the sass npm package) is required for compiling Sass files.
Agent activity
4 hits · last 30 days
node
4
Resources
express-dart-sass — npm install express-dart-sass · libregistry