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  JsonWebTokenError: invalid signature while verifying token using JWT

Leave a Reply

Your email address will not be published.

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