webpack-middleware is a wrapper that enables running the Webpack compiler as a middleware for Connect-compatible servers like Express.js or Browsersync. It serves compiled assets from memory, offering faster rebuilds during development without writing files to disk. This specific package, at version 1.5.1, is a fork of `webpack-dev-middleware` designed to better support isomorphic (mixed web/Node.js) bundles. However, it has not been updated since 2016 and is tied to Webpack versions less than 3, making it incompatible with modern Webpack 4 or 5. Users should generally prefer the actively maintained `webpack-dev-middleware` for current projects.
npm install webpack-middlewareVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `webpack-middleware` with Browsersync to serve Webpack bundles from memory and proxy requests to a Node.js application, suitable for isomorphic development.
Migrate to `webpack-dev-middleware`. This involves changing the package name and potentially updating configuration options, as the APIs may have diverged slightly over time. `webpack-dev-middleware` has continuous updates and supports recent Webpack versions.
Given the abandonment of this package, there is no direct fix. The only solution is to migrate to `webpack-dev-middleware` which has addressed these issues in later versions.
Either downgrade your Webpack installation to a compatible v1 or v2 version (not recommended for new projects), or switch to the actively maintained `webpack-dev-middleware` which supports modern Webpack versions.
Install webpack locally: `npm install webpack`
Ensure your server framework is Connect-compatible (e.g., Express.js, Koa via `koa-connect`, Browsersync) or correctly applies the middleware. The `webpack-dev-middleware` documentation (which this package is based on) provides examples for various frameworks.
This package is obsolete for modern Webpack. Uninstall `webpack-middleware` and `webpack-dev-middleware` (if also present) and install `webpack-dev-middleware` instead. `npm uninstall webpack-middleware; npm install webpack-dev-middleware`.