node.js 报错 throw new TypeError(‘app.use() requires a middleware function‘)

简介: node.js 报错 throw new TypeError(‘app.use() requires a middleware function‘)

错误


C:\Users\Yang\Desktop\blog\node_modules\express\lib\application.js:210
    throw new TypeError('app.use() requires a middleware function')
    ^
TypeError: app.use() requires a middleware function
    at Function.use (C:\Users\Yang\Desktop\blog\node_modules\express\lib\application.js:210:11)
    at Object.<anonymous> (C:\Users\Yang\Desktop\blog\app.js:31:5)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47


原因


原因是因为 没有导出 module


(完全大意了,没有闪)


在 router.js 结尾中加入


module.exports = router;
相关文章
|
5天前
|
JSON 小程序 JavaScript
uni-app开发微信小程序的报错[渲染层错误]排查及解决
uni-app开发微信小程序的报错[渲染层错误]排查及解决
78 7
|
3天前
|
Linux Python
【Azure Function】Python Function部署到Azure后报错No module named '_cffi_backend'
ERROR: Error: No module named '_cffi_backend', Cannot find module. Please check the requirements.txt file for the missing module.
|
4天前
|
JavaScript 前端开发 开发工具
【Azure Developer】使用JavaScript通过SDK进行monitor-query的client认证报错问题
AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found. Check to make sure you have the correct tenant ID and are signing into the correct cloud. Check with your subscription administrator, this may happen if there are no active subscriptions for the tenant.
构造函数(function)可以使用 new 生成实例,箭头函数可以吗
构造函数使用 `new` 关键字可以生成实例对象,而箭头函数则不能用作构造函数,因为它没有自己的 `this` 上下文,使用 `new` 调用会抛出错误。
|
10天前
|
JavaScript 前端开发
原生js常见报错及其处理方案
原生js常见报错及其处理方案
13 0
|
2月前
【Azure Logic App】使用Outlook.com发送邮件遇到429报错
【Azure Logic App】使用Outlook.com发送邮件遇到429报错
|
2月前
|
开发工具 git
【Azure App Service】App Service设置访问限制后,使用git clone代码库出现403报错
【Azure App Service】App Service设置访问限制后,使用git clone代码库出现403报错
|
2月前
|
开发框架 .NET Windows
【App Service】在App Service中配置Virtual applications and directories,访问目录中的静态文件报错404
【App Service】在App Service中配置Virtual applications and directories,访问目录中的静态文件报错404
|
2月前
|
缓存
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
|
2月前
|
安全 前端开发 网络安全
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
119 0