{"id":17610,"library":"express-formidable","title":"Express Formidable Middleware","description":"express-formidable is an Express.js middleware designed to simplify parsing of various form data types, including `application/x-www-form-urlencoded`, `application/json`, and notably `multipart/form-data` for file uploads. It acts as a bridge, wrapping the core `formidable` Node.js module to integrate its parsing capabilities directly into the Express request-response cycle, populating `req.fields` for non-file data and `req.files` for uploaded files. The package's current stable version is 1.2.0, which was last published over seven years ago. Due to this prolonged inactivity, the project is considered abandoned, with no ongoing maintenance or updates. This lack of development means it does not support modern JavaScript features like ESM out-of-the-box and is unlikely to be compatible with recent major versions of Express or `formidable`. Developers looking for robust form data parsing, especially with file uploads, should consider actively maintained alternatives like `multer` or directly using the latest versions of `formidable` with explicit Express integration, or the community-maintained `express-formidable-v2`.","status":"abandoned","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/noraesae/express-formidable","tags":["javascript","express","middleware","formidable"],"install":[{"cmd":"npm install express-formidable","lang":"bash","label":"npm"},{"cmd":"yarn add express-formidable","lang":"bash","label":"yarn"},{"cmd":"pnpm add express-formidable","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core library for parsing form data and file uploads, wrapped by this middleware.","package":"formidable","optional":false},{"reason":"Peer dependency, as this is an Express.js middleware.","package":"express","optional":false}],"imports":[{"note":"The package is CommonJS-only and does not provide ESM exports. Use `require`.","wrong":"import expressFormidable from 'express-formidable';","symbol":"expressFormidable","correct":"const expressFormidable = require('express-formidable');"},{"note":"TypeScript types are available via `@types/express-formidable` and extend the `Express.Request` object, but the package itself has no named exports.","wrong":"import { FormidableMiddleware } from 'express-formidable';","symbol":"FormidableMiddleware","correct":"import ExpressFormidable from 'express-formidable';\n// For TypeScript type declarations\nimport { Fields, Files } from 'formidable';\ndeclare global { namespace Express { interface Request { fields?: Fields; files?: Files; } } }"}],"quickstart":{"code":"const express = require('express');\nconst formidableMiddleware = require('express-formidable');\n\nconst app = express();\nconst PORT = process.env.PORT || 3000;\n\n// Apply the formidable middleware\napp.use(formidableMiddleware({\n  uploadDir: './uploads', // Specify upload directory (must exist)\n  keepExtensions: true,\n  multiples: true // Allow multiple files for the same field name\n}));\n\n// Create an endpoint to handle file uploads\napp.post('/upload', (req, res) => {\n  console.log('Received upload request.');\n  console.log('Fields:', req.fields); // Non-file fields\n  console.log('Files:', req.files);   // Uploaded files\n\n  if (req.files && Object.keys(req.files).length > 0) {\n    res.status(200).send('File(s) uploaded successfully!');\n  } else {\n    res.status(400).send('No files were uploaded or an error occurred.');\n  }\n});\n\n// A simple GET endpoint to show it works\napp.get('/', (req, res) => {\n  res.status(200).send('<h1>Upload Service</h1><form action=\"/upload\" method=\"post\" enctype=\"multipart/form-data\"><input type=\"file\" name=\"myFile\" multiple><input type=\"text\" name=\"description\"><button type=\"submit\">Upload</button></form>');\n});\n\napp.listen(PORT, () => {\n  console.log(`Server listening on http://localhost:${PORT}`);\n  console.log('Ensure `./uploads` directory exists.');\n});","lang":"javascript","description":"This example demonstrates a basic Express server using express-formidable to handle file uploads and form fields via a POST request."},"warnings":[{"fix":"Migrate to `multer` or directly integrate `formidable` (latest version) with Express.js, using `express-formidable-v2` as a drop-in replacement if direct migration is not feasible.","message":"The `express-formidable` package is abandoned and has not been updated in over seven years. It lacks support for modern Node.js versions, ECMAScript modules (ESM), and recent breaking changes in Express.js or the underlying `formidable` library. It is strongly advised to use actively maintained alternatives like `multer` or `formidable` directly.","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"Ensure `express-formidable` is the only middleware responsible for parsing form data on routes where file uploads or complex form data are expected. Do not apply `express.json()` or `express.urlencoded()` to these specific routes or globally before `express-formidable`.","message":"Using `express-formidable` concurrently with `body-parser` middleware (e.g., `app.use(express.json())` or `app.use(express.urlencoded())`) will cause issues, as both attempt to consume the incoming request stream. This can lead to requests hanging or form data not being parsed correctly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to a modern, maintained form parsing library that explicitly supports your current Node.js version.","message":"The package only explicitly supports Node.js versions `>=8`. Using it with significantly newer Node.js versions (e.g., Node.js 16+) may lead to unexpected behavior or compatibility issues due to underlying API changes in Node.js core or dependencies over time.","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"For ESM projects, consider alternatives. If you must use it, it might require a CommonJS wrapper or bundler configuration, but this is not recommended given its abandoned status.","message":"The package is CommonJS-only and does not provide ECMAScript Module (ESM) exports. Attempting to `import expressFormidable from 'express-formidable'` in an ESM context will result in a runtime error.","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 `const formidableMiddleware = require('express-formidable');` is correct and the package is installed. Verify the environment is CommonJS.","cause":"Attempting to use `express-formidable` without correctly requiring the module, or if the module fails to load.","error":"TypeError: app.use() requires middleware functions but got a [object Undefined]"},{"fix":"Remove or selectively apply other body parsing middleware. `express-formidable` should be used as the primary body parser for routes handling `multipart/form-data`. Ensure `app.use(formidableMiddleware())` is called before any routes that expect to use it.","cause":"Another middleware (e.g., `express.json()` or `body-parser`) has already consumed the request stream before `express-formidable` could process it, or the middleware is not properly applied to the route.","error":"Request hangs indefinitely / `req.fields` and `req.files` are undefined or empty"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}