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;
上一篇:第一个vue程序


下一篇:Centos7部署Zookeeper单节点