Skip to content

TypeError: Router.use() requires a middleware function but got a Object – How to fix this Express/Node.js error?

TypeError: Router.use() requires a middleware function but got a Object – How to fix this Express/Node.js error? You would typically face this error when you define a new router and start your node.js app. But did you export your router? Nope.

Add this line at the end of your router definitions.

module.exports = router;
See also  Add custom CSS to your Swagger documentation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.