Registry / devops / express-minify

express-minify

JSON →
library1.0.0jsnpmunverified

Express middleware that automatically minifies and caches JavaScript, CSS, and JSON responses. Supports compiling LESS/SASS/Stylus/CoffeeScript before minifying. Version 1.0.0 is stable, with a long history but recent releases are infrequent. Key differentiators: automatic content-type detection, in-memory or disk caching, and per-response control. Unlike other minification middlewares, it does not require specifying a source directory and can work alongside express.static and compression.

npm install express-minify
INSTALL
IMPORT
SIG · EXPRESS-MINIFY
E
express-minify
devopsjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import minify from 'express-minify'
const minify = require('express-minify')
The package exports a function that creates the middleware. CJS require works too, but ESM import is recommended for modern apps.

Shows basic setup with express, compression, static files, and minify middleware. Cache is disabled for demonstration.

import express from 'express'; import compression from 'compression'; import minify from 'express-minify'; const app = express(); app.use(compression()); app.use(minify({ cache: false })); app.use(express.static('public')); app.listen(3000);
Debug
Known issues
gotchaCache directory must be writable if cache option is a string path.
fix
Ensure the directory exists and is writable by the Node process, or use in-memory cache (cache: false).
affects: >=1.0.0
gotchaMiddleware order matters: compression should be before minify if you want to GZip the minified output.
fix
Place compression() before minify() in the middleware stack.
affects: >=1.0.0
deprecatedThe jsonMatch option exists but JSON minification is not recommended as it may break JSON if whitespace is significant.
fix
Set jsonMatch: false to disable JSON minification.
affects: >=1.0.0
Errors
Common errors & fixes
Error: EACCES: permission denied, mkdir '/path/to/cache'
Cache directory is not writable.
fix
Use a writable directory or disable cache: app.use(minify({ cache: false }));
TypeError: minify is not a function
Using default import when package is CJS and requires .default.
fix
Use const minify = require('express-minify').default; or switch to ESM import minify from 'express-minify';
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
uglify-jsoptionalDefault JavaScript minifier; can be overridden with custom module via uglifyJsModule option.
Agent activity
2 hits · last 30 days
node
2
Resources
express-minify — npm install express-minify · libregistry