{"id":17710,"library":"iced-coffee-middleware","title":"Coffee-Script Connect/Express Middleware","description":"iced-coffee-middleware (also known as `coffee-middleware`) is a Connect/Express middleware designed for on-the-fly compilation of CoffeeScript files (`.coffee`) into JavaScript. Currently at version 0.2.1, it provides functionality to dynamically serve compiled JavaScript, offering options such as `force` for continuous recompilation, `bare` for compilation without the top-level safety wrapper, and `encodeSrc` for embedding base64 source maps. This package leverages patterns from `less-middleware` and is built for integration with older `connect` and `express` versions that utilized `createServer()` and `app.configure()`. Due to its reliance on these long-deprecated APIs and the declining prevalence of CoffeeScript in new web development, the package's active maintenance and applicability to modern Node.js ecosystems are highly questionable. Its development cadence is effectively halted, with no significant updates in many years, making it primarily a historical artifact rather than a viable solution for contemporary projects.","status":"abandoned","version":"0.2.1","language":"javascript","source_language":"en","source_url":"git://github.com/emnh/coffee-middleware","tags":["javascript","coffee-script","middleware","express","connect"],"install":[{"cmd":"npm install iced-coffee-middleware","lang":"bash","label":"npm"},{"cmd":"yarn add iced-coffee-middleware","lang":"bash","label":"yarn"},{"cmd":"pnpm add iced-coffee-middleware","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core compiler for .coffee files.","package":"coffee-script","optional":false},{"reason":"Peer dependency for middleware integration. Requires an older version.","package":"connect","optional":false},{"reason":"Peer dependency for middleware integration. Requires an older version (pre-4.x).","package":"express","optional":false}],"imports":[{"note":"This package is CommonJS-only and relies on `require()`. It is not compatible with modern ESM `import` statements or contemporary build pipelines.","wrong":"import coffeeMiddleware from 'coffee-middleware';","symbol":"coffeeMiddleware","correct":"const coffeeMiddleware = require('coffee-middleware');"}],"quickstart":{"code":"const express = require('express');\nconst coffeeMiddleware = require('coffee-middleware');\nconst path = require('path');\nconst fs = require('fs');\n\n// Create a dummy public directory and a .coffee file for demonstration\nconst publicDir = path.join(__dirname, 'public');\nconst coffeeFilePath = path.join(publicDir, 'hello.coffee');\n\nif (!fs.existsSync(publicDir)) {\n  fs.mkdirSync(publicDir);\n}\nfs.writeFileSync(coffeeFilePath, 'console.log \"Hello from CoffeeScript!\"');\n\n// Note: express.createServer() and app.configure() are deprecated in modern Express.\n// This example uses patterns from Express 3.x to demonstrate functionality.\nconst app = express();\n\n// Mock the old `configure` method for compatibility with the example structure\napp.configure = function(fn) { fn(); }; \n\napp.configure(function () {\n  app.use(coffeeMiddleware({\n    src: publicDir,\n    bare: true, // Compile without the top-level safety wrapper\n    compress: true, // Example option (may require 'uglify-js' in older versions)\n    force: true // Ensure recompilation on each request for demo\n  }));\n  // Serve static files, ensuring compiled JS files can be accessed\n  app.use(express.static(publicDir));\n});\n\nconst PORT = 3000;\napp.listen(PORT, () => {\n  console.log(`Server running on http://localhost:${PORT}`);\n  console.log(`Try accessing http://localhost:${PORT}/hello.js`);\n  console.log(`(This will compile and serve public/hello.coffee as JavaScript)`);\n});\n\n// To run this example, you would typically need to install older versions:\n// npm install express@3.x coffee-middleware connect@2.x","lang":"javascript","description":"This quickstart demonstrates how to set up `coffee-middleware` with an older Express 3.x application to compile and serve CoffeeScript files on demand, including a basic example `.coffee` file and a server setup."},"warnings":[{"fix":"Consider using modern build tools (e.g., Webpack, Rollup, Vite) to precompile CoffeeScript (or switch to TypeScript/modern JS) or use an Express 3.x compatible environment for this middleware.","message":"This package relies on `express.createServer()` and `app.configure()` which were deprecated in Express 4.x. It is not compatible with modern Express applications without significant bridging or downgrading Express versions.","severity":"breaking","affected_versions":">=4.0.0 (for Express)"},{"fix":"Evaluate if CoffeeScript is still the appropriate language for your project. Consider migrating to TypeScript or plain JavaScript with a modern build setup for better tooling and community support.","message":"The use of CoffeeScript for new web development projects has largely declined. Modern projects typically use TypeScript or contemporary JavaScript with transpilers like Babel.","severity":"deprecated","affected_versions":"All"},{"fix":"Ensure your project is configured for CommonJS modules if using this package, or use `require()` within an ESM module if supported by your runtime/transpiler setup (e.g., Node.js with `createRequire`).","message":"This package is CommonJS-only and cannot be directly `import`ed in an ESM module context. Attempting to do so will result in a runtime error.","severity":"gotcha","affected_versions":"All"},{"fix":"Use with caution in production. Review the source code for potential vulnerabilities or unhandled edge cases. Consider if a more mature and maintained solution exists for your needs.","message":"The package is at version 0.2.1, indicating an early development stage and potential lack of stability or extensive testing for production environments. It has not seen updates for many years.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"This middleware is designed for Express 3.x. You either need to downgrade Express (e.g., `npm install express@3.x`) or refactor your application to not use this legacy middleware.","cause":"Attempting to use `express.createServer()` with Express 4.x or later.","error":"TypeError: app.createServer is not a function"},{"fix":"Ensure the package is installed: `npm install coffee-middleware` (or `npm install iced-coffee-middleware` if that was the intended name, though the readme uses `coffee-middleware`). Check `node_modules` and your `package.json`.","cause":"The package is not installed or the Node.js module resolution path is incorrect.","error":"Error: Cannot find module 'coffee-middleware'"},{"fix":"This package is CommonJS. Use `const coffeeMiddleware = require('coffee-middleware');` and ensure your file is treated as CommonJS (e.g., no `\"type\": \"module\"` in `package.json` or rename to `.cjs`).","cause":"Attempting to `import` `coffee-middleware` in a CommonJS context or using `require()` in an ESM context without proper configuration.","error":"SyntaxError: Cannot use import statement outside a module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}