{"id":26846,"library":"compress","title":"compress","description":"Compress is a Node.js middleware for HTTP message compression, supporting gzip, deflate, and brotli encodings. The current stable version is 0.99.0, with infrequent releases. It differs from alternatives like compression by focusing on simplicity and low overhead, but is less actively maintained. Suitable for compressing HTTP responses in Express/Connect apps.","status":"active","version":"0.99.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install compress","lang":"bash","label":"npm"},{"cmd":"yarn add compress","lang":"bash","label":"yarn"},{"cmd":"pnpm add compress","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"native Node.js compression module used for gzip/deflate/brotli","package":"zlib","optional":true}],"imports":[{"note":"ESM default import; no named exports.","wrong":"const compress = require('compress')","symbol":"compress","correct":"import compress from 'compress'"},{"note":"CJS require pattern; the default export is on .default property.","wrong":"const compress = require('compress')","symbol":"compress","correct":"const compress = require('compress').default"},{"note":"If the package exposes compressObj as a named export (check docs).","wrong":"const { compress } = require('compress')","symbol":"compressObj","correct":"import { compressObj } from 'compress'"}],"quickstart":{"code":"import compress from 'compress';\nimport http from 'http';\n\nconst server = http.createServer((req, res) => {\n  compress(req, res, () => {\n    res.writeHead(200, { 'Content-Type': 'text/plain' });\n    res.end('Hello, World!');\n  });\n});\n\nserver.listen(3000, () => {\n  console.log('Server running on port 3000');\n});","lang":"javascript","description":"Creates an HTTP server that compresses responses using the compress middleware."},"warnings":[{"fix":"Migrate to the 'compression' npm package for better maintenance.","message":"compress 0.x is not actively maintained; consider alternatives like compression.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Ensure the response object has writable stream methods (e.g., from http.createServer).","message":"The compress function expects an HTTP response with a writable stream; fails if used improperly.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use `const compress = require('compress').default;`","cause":"Incorrect default import in CommonJS environment.","error":"TypeError: compress is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}