美文网首页
express因为为导出router引起的错误

express因为为导出router引起的错误

作者: 放风筝的小小马 | 来源:发表于2018-05-15 00:38 被阅读81次
     throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
          ^
    
    TypeError: Router.use() requires a middleware function but got a Object
        at Function.use (/Users/zhangjie/myProjects/blog-manage/node_modules/express/lib/router/index.js:458:13)
        at Function.<anonymous> (/Users/zhangjie/myProjects/blog-manage/node_modules/express/lib/application.js:220:21)
        at Array.forEach (<anonymous>)
        at Function.use (/Users/zhangjie/myProjects/blog-manage/node_modules/express/lib/application.js:217:7)
        at module.exports (/Users/zhangjie/myProjects/blog-manage/server/controler/index.js:7:7)
        at Object.<anonymous> (/Users/zhangjie/myProjects/blog-manage/server/index.js:25:1)
        at Module._compile (module.js:641:30)
        at Object.Module._extensions..js (module.js:652:10)
        at Module.load (module.js:560:32)
        at tryModuleLoad (module.js:503:12)
    

    在编写接口时,因为未将router通过 module.export导出, 导致出现上面的错误

    相关文章

      网友评论

          本文标题:express因为为导出router引起的错误

          本文链接:https://www.haomeiwen.com/subject/bpisdftx.html