{"id":17521,"library":"browserify-dev-middleware","title":"Browserify Development Middleware","description":"Browserify Dev Middleware provides an Express/Connect-compatible middleware for Node.js environments, designed to compile Browserify files on request specifically for development purposes. It enables dynamic bundling of client-side JavaScript, supporting features like specifying a source directory for assets, applying Browserify transforms (e.g., `jadeify`), global transforms (e.g., `deamdify`), and passing arbitrary Browserify options directly. This approach allows developers to avoid pre-compilation steps during local development, serving fresh bundles dynamically. The package is currently at version 1.5.0. However, its GitHub repository was archived in October 2021, indicating it is no longer actively maintained, making its release cadence effectively ceased. Its key differentiator was its simplicity in integrating on-demand Browserify compilation into existing Node.js servers, contrasting with more complex static asset pipelines.","status":"abandoned","version":"1.5.0","language":"javascript","source_language":"en","source_url":"git://git@github.com/artsy/browserify-dev-middleware","tags":["javascript","browserify","middleware","assets"],"install":[{"cmd":"npm install browserify-dev-middleware","lang":"bash","label":"npm"},{"cmd":"yarn add browserify-dev-middleware","lang":"bash","label":"yarn"},{"cmd":"pnpm add browserify-dev-middleware","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core bundler dependency for compilation functionality.","package":"browserify","optional":false}],"imports":[{"note":"This package is CommonJS-only and does not support ES module `import` syntax.","wrong":"import browserifyDevMiddleware from 'browserify-dev-middleware';","symbol":"browserifyDevMiddleware","correct":"const browserifyDevMiddleware = require('browserify-dev-middleware');"}],"quickstart":{"code":"const express = require('express');\nconst browserifyDevMiddleware = require('browserify-dev-middleware');\nconst path = require('path');\n\nconst app = express();\nconst assetsPath = path.join(__dirname, 'assets');\n\n// Create a dummy asset file for demonstration\nconst fs = require('fs');\nif (!fs.existsSync(assetsPath)) {\n  fs.mkdirSync(assetsPath);\n}\nfs.writeFileSync(path.join(assetsPath, 'commit.js'), 'module.exports = { message: \"Hello from browserify!\" };');\n\napp.use(browserifyDevMiddleware({\n  src: assetsPath,\n  // Example of adding a transform, typically 'jadeify' or similar\n  // For this quickstart, we'll just demonstrate general options.\n  // transforms: [require('some-browserify-transform')] \n  noParse: [],\n  insertGlobals: true\n}));\n\napp.get('/', (req, res) => {\n  res.send(`\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Browserify Dev Middleware Example</title>\n    </head>\n    <body>\n      <h1>Check console for bundled output</h1>\n      <script src=\"/commit.js\"></script>\n      <script>\n        // commit.js will be served at /commit.js thanks to the middleware\n        fetch('/commit.js')\n          .then(response => response.text())\n          .then(text => console.log('Bundle content:', text))\n          .catch(error => console.error('Error fetching bundle:', error));\n\n        // You can also try to access window.module.exports directly if the bundle exposes it.\n        // This depends on browserify's output format.\n      </script>\n    </body>\n    </html>\n  `);\n});\n\nconst PORT = process.env.PORT || 3000;\napp.listen(PORT, () => {\n  console.log(`Server listening on http://localhost:${PORT}`);\n  console.log(`Access /commit.js in your browser to see the bundled file.`);\n});\n","lang":"javascript","description":"This quickstart demonstrates how to integrate `browserify-dev-middleware` with an Express application to serve a Browserify-bundled file on demand. It configures the middleware to watch a specified `assets` directory and serves `commit.js` dynamically, which can then be included in an HTML page."},"warnings":[{"fix":"Evaluate modern asset bundling solutions like Webpack, Rollup, Vite, or a more actively maintained Browserify middleware (e.g., `browserify-middleware` by ForbesLindesay) for development environments.","message":"The `browserify-dev-middleware` GitHub repository was archived in October 2021. This package is no longer actively maintained, meaning there will be no further bug fixes, security patches, or feature updates. Users should consider migrating to alternative solutions for long-term projects.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"Ensure your Node.js project uses CommonJS modules (`.js` files with `require`/`module.exports`, or `type: \"commonjs\"` in `package.json`). If integrating with an ES Module project, a CJS wrapper or dynamic `import()` might be required, but it's generally advised to use an ESM-compatible bundler.","message":"This package is built for CommonJS (CJS) environments and uses `require()` for module loading. It does not natively support ES Modules (`import`/`export`) syntax.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Test thoroughly on your target Node.js version. For production or new projects, consider modern alternatives that are actively maintained and support current Node.js LTS releases.","message":"The package's Node.js engine requirement is `>= 4.0`. While it might function on newer Node.js versions, it has not been tested or updated for compatibility with recent Node.js releases, potentially leading to unforeseen issues, especially with breaking changes in Node.js APIs or internal modules.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Ensure you have an Express or Connect app instance (`const app = express();` or `const app = connect();`) and that `app.use` is called on that instance.","cause":"The `browserify-dev-middleware` package returns a middleware function. This error typically occurs when attempting to use it with a framework that doesn't provide an `app.use` method, or if `app` is not correctly initialized as an Express/Connect application.","error":"TypeError: app.use is not a function"},{"fix":"Change your import statement to use CommonJS `require()`: `const browserifyDevMiddleware = require('browserify-dev-middleware');`.","cause":"This error arises when trying to use ES module `import` syntax (`import browserifyDevMiddleware from 'browserify-dev-middleware';`) in a Node.js project configured for CommonJS, or in a script where `browserify-dev-middleware` expects CommonJS `require()`.","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}