Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
getProxyMiddleware
✓ var getProxyMiddleware = require('grunt-middleware-proxy/lib/Utils').getProxyMiddleware;
✗ var getProxyMiddleware = require('grunt-middleware-proxy').getProxyMiddleware;
The main export is not a function; you must require the 'Utils' submodule and call getProxyMiddleware().
ProxyMiddleware (default import)
✓ import { getProxyMiddleware } from 'grunt-middleware-proxy/lib/Utils';
✗ import proxyMiddleware from 'grunt-middleware-proxy';
This package does not have a default export; use named import from the Utils path.
grunt.loadNpmTasks
✓ grunt.loadNpmTasks('grunt-middleware-proxy');
✗ require('grunt-middleware-proxy');
In Gruntfile, use loadNpmTasks to register the plugin, not require directly (though require is used inside middleware function).
Shows minimal Gruntfile setup with grunt-contrib-connect and middleware proxy, including proxies configuration.
// Install
// npm install grunt-middleware-proxy --save-dev
// Gruntfile.js
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-middleware-proxy');
grunt.initConfig({
connect: {
server: {
options: {
port: 9000,
hostname: 'localhost',
middleware: function(connect, options, middlewares) {
var getProxyMiddleware = require('grunt-middleware-proxy/lib/Utils').getProxyMiddleware;
middlewares.unshift(getProxyMiddleware());
return middlewares;
}
},
proxies: [
{
context: '/api',
host: 'example.com',
port: 8080,
https: false,
rewriteHost: true
}
]
}
}
});
grunt.registerTask('default', ['connect:server']);
};
Errors
Common errors & fixes
TypeError: grunt-middleware-proxy is not a function
Requiring the main package directly instead of the Utils submodule.
fixChange require('grunt-middleware-proxy') to require('grunt-middleware-proxy/lib/Utils').getProxyMiddleware() Error: connect.multipart() is not a function
Incompatibility with newer versions of grunt-contrib-connect where the middleware API changed.
fixEnsure you are using a compatible version of grunt-contrib-connect (e.g., ^0.11.0).
Error: listen EADDRINUSE :::9000
Port conflict; usually another process is using the same port.
fixChange the port in connect options or kill the process using the port.
Audit
Dependencies
grunt-contrib-connectrequiredThis plugin is middleware for grunt-contrib-connect; it must be installed and configured alongside it.
http-proxyrequiredUsed internally for proxying HTTP/HTTPS requests.