{"id":18889,"library":"ui5-middleware-servestatic","title":"UI5 serve static middleware","description":"ui5-middleware-servestatic v3.5.0 is a community-driven middleware for the UI5 tooling that serves static resources during development. It integrates serve-static to serve files from a root path or an npm package path. Compatible with @ui5/cli@3.0.0+ and specVersion 3.0. Release cadence is moderate, with fixes and features driven by community needs. Key differentiator: simple configuration for custom static resource serving in UI5 projects, supporting environment variables and runtime path resolution.","status":"active","version":"3.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/ui5-community/ui5-ecosystem-showcase","tags":["javascript"],"install":[{"cmd":"npm install ui5-middleware-servestatic","lang":"bash","label":"npm"},{"cmd":"yarn add ui5-middleware-servestatic","lang":"bash","label":"yarn"},{"cmd":"pnpm add ui5-middleware-servestatic","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required at version 3.0.0+ for specVersion 3.0 support","package":"@ui5/cli","optional":false},{"reason":"Used internally to serve static files","package":"serve-static","optional":false}],"imports":[{"note":"ESM is preferred, but CJS require also works as the package exports both.","wrong":"const middleware = require('ui5-middleware-servestatic')","symbol":"default","correct":"import middleware from 'ui5-middleware-servestatic'"},{"note":"Named export for the core serveStatic function, used for custom integrations.","wrong":"import serveStatic from 'ui5-middleware-servestatic'","symbol":"serveStatic","correct":"import { serveStatic } from 'ui5-middleware-servestatic'"},{"note":"The package exports a `middleware` named export as well.","wrong":"Import the default export and use it as middleware.","symbol":"middleware","correct":"import { middleware } from 'ui5-middleware-servestatic'"}],"quickstart":{"code":"// Install: npm install ui5-middleware-servestatic --save-dev\n// In ui5.yaml:\n// server:\n//   customMiddleware:\n//   - name: ui5-middleware-servestatic\n//     afterMiddleware: compression\n//     mountPath: /resources\n//     configuration:\n//       rootPath: /path/to/static/resources\n\n// Implementation example:\nimport express from 'express';\nimport { middleware } from 'ui5-middleware-servestatic';\n\nconst app = express();\napp.use('/resources', middleware({\n  rootPath: '/path/to/static/resources',\n  debug: true\n}));\n\napp.listen(3000, () => console.log('Server running on port 3000'));\n","lang":"typescript","description":"Shows installation, configuration in ui5.yaml, and programmatic usage of the middleware with Express."},"warnings":[{"fix":"Upgrade @ui5/cli to version 3 or later and update ui5.yaml specVersion to 3.0.","message":"Major version 3 requires @ui5/cli@3.0.0+ and specVersion 3.0.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use absolute paths or prefix with env. for environment variables.","message":"The `rootPath` option with a relative path is deprecated; use absolute paths or environment variables instead.","severity":"deprecated","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Provide only one of the two options to avoid confusion.","message":"If both `rootPath` and `npmPackagePath` are provided, `rootPath` takes precedence.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install ui5-middleware-servestatic --save-dev`.","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'ui5-middleware-servestatic'"},{"fix":"Ensure the package is listed in devDependencies and npm install succeeded.","cause":"UI5 CLI cannot locate the middleware in ui5.yaml dependencies.","error":"ERROR #UI5/00012: Middleware 'ui5-middleware-servestatic' not found"},{"fix":"Add `configuration: { rootPath: '...' }` to your middleware definition.","cause":"Configuration object missing in ui5.yaml under the middleware entry.","error":"TypeError: Cannot read properties of undefined (reading 'rootPath')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}