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.
npm install koa-stylusVerified import paths — ran on the pinned version, not inferred.
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.
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.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.
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.
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.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.