{"id":17759,"library":"koa-stylus","title":"Koa Stylus Middleware","description":"koa-stylus provides middleware to integrate the Stylus CSS preprocessor with Koa.js web applications. This package is extremely old and was last published over a decade ago (version 0.1.1, 11 years ago). It is designed exclusively for Koa v1.x, which utilized generator functions for middleware. Modern Koa versions (v2.x and v3.x, which use `async/await`) are incompatible with this middleware without significant modifications or a compatibility layer. The package is effectively abandoned, has no ongoing development or release cadence, and lacks support for contemporary Node.js or Koa features. Its primary differentiator was its simple integration with the then-current Koa API for Stylus compilation on the fly.","status":"abandoned","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/yosssi/koa-stylus","tags":["javascript","koa","stylus"],"install":[{"cmd":"npm install koa-stylus","lang":"bash","label":"npm"},{"cmd":"yarn add koa-stylus","lang":"bash","label":"yarn"},{"cmd":"pnpm add koa-stylus","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency for the Koa web framework, specifically Koa v1.x's generator-based middleware.","package":"koa","optional":false},{"reason":"Runtime dependency for the Stylus CSS preprocessor engine, used to compile .styl files.","package":"stylus","optional":false}],"imports":[{"note":"This package is CJS-only. Koa 1.x and older Node.js versions relied on CommonJS `require()`.","wrong":"import stylus from 'koa-stylus';","symbol":"stylus","correct":"const stylus = require('koa-stylus');"},{"note":"The example uses `require('koa')`, consistent with Koa 1.x. Modern Koa (v2+) uses `import Koa from 'koa'` for ESM.","wrong":"import Koa from 'koa';","symbol":"Koa","correct":"const Koa = require('koa');"}],"quickstart":{"code":"const Koa = require('koa');\nconst stylus = require('koa-stylus');\nconst serve = require('koa-static');\nconst app = new Koa();\n\n// Configure Stylus middleware to compile .styl files in the './public' directory\napp.use(stylus('./public'));\n\n// Serve static files from the './public' directory\napp.use(serve('./public'));\n\n// Listen on port 3000\napp.listen(3000, () => {\n  console.log('Koa Stylus server listening on http://localhost:3000');\n  console.log('Ensure you have a `public` directory with .styl files and other static assets.');\n});\n","lang":"javascript","description":"This example demonstrates how to set up `koa-stylus` with Koa v1.x to automatically compile Stylus files and serve them alongside other static assets."},"warnings":[{"fix":"For modern Koa (v2+), consider manually compiling Stylus or using a build pipeline. If `koa-stylus` functionality is critical, you would need to wrap it with `koa-convert` (e.g., `app.use(convert(stylus('./public')))`) and potentially deal with other incompatibilities.","message":"This package is built for Koa v1.x, which uses generator functions for middleware. Koa v2.x and later transitioned to `async/await` functions, making `koa-stylus` fundamentally incompatible with modern Koa versions without a `koa-convert`-like shim or extensive refactoring.","severity":"breaking","affected_versions":">=2.0.0 (Koa)"},{"fix":"It is strongly recommended to avoid this package. Instead, preprocess Stylus into CSS during your build step (e.g., using Gulp, Webpack, or a simple npm script) and serve the resulting static CSS files directly.","message":"The `koa-stylus` package is over a decade old and has been abandoned. It has not received updates for compatibility with newer Node.js versions, security patches, or feature enhancements. Using unmaintained software can expose applications to security vulnerabilities or unexpected behavior with newer environments.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always audit your dependencies. For `stylus` specifically, ensure you are using a recent, uncompromised version if you decide to use it. For `koa-stylus`, the risk is compounded by its abandonment.","message":"The underlying `stylus` package itself (the CSS preprocessor) has experienced supply chain issues, including being temporarily removed from the npm registry due to a maintainer's account compromise. While these issues were resolved for `stylus`, the general lack of maintenance of `koa-stylus` increases the risk of unpatched vulnerabilities or dependency conflicts.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"This error indicates an incompatibility with modern Koa versions. You can try to use `koa-convert` as `app.use(require('koa-convert')(stylus('./public')));`, but full compatibility is not guaranteed, and migrating away from this middleware is recommended.","cause":"`koa-stylus` is a Koa v1.x middleware which uses generator functions, while Koa v2.x and newer expect async functions.","error":"TypeError: app.use() requires a generator function"},{"fix":"Ensure 'stylus' is correctly listed in your `package.json` and run `npm install`. If issues persist, check the official `stylus` npm page for any current availability problems or security advisories.","cause":"The 'stylus' package, a dependency of 'koa-stylus', was not installed or was temporarily unavailable in the npm registry (as happened in the past due to a security incident).","error":"Cannot find module 'stylus'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}