美文网首页
koahub-wemall 发生报错 Error: The se

koahub-wemall 发生报错 Error: The se

作者: 雪白小狐狸 | 来源:发表于2018-10-12 09:26 被阅读0次

    今天在使用一套叫做 koahub-wemall 的现成商城源码的时候发生了一个诡异的报错,报错内容大概如下

    Error: The session middleware not found
        at Koahub.loadMiddlewares (/home/snowfox/code/docker/koa-shop/koahub-wemall/node_modules/koahub/app/index.js:158:27)
        at Koahub.init (/home/snowfox/code/docker/koa-shop/koahub-wemall/node_modules/koahub/app/index.js:196:14)
        at new Koahub (/home/snowfox/code/docker/koa-shop/koahub-wemall/node_modules/koahub/app/index.js:28:14)                                                                                  
        at Object.<anonymous> (/home/snowfox/code/docker/koa-shop/koahub-wemall/app/index.js:13:13)                                                                                              
        at Module._compile (module.js:660:30)                                                                                                                                                    
        at Object.Module._extensions..js (module.js:671:10)                                                                                                                                      
        at Module.load (module.js:573:32)                                                                                                                                                        
        at tryModuleLoad (module.js:513:12)                                                                                                                                                      
        at Function.Module._load (module.js:505:3)
        at Function.Module.runMain (module.js:701:10)
        at startup (bootstrap_node.js:190:16)
        at bootstrap_node.js:662:3
    
    

    在神奇的谷歌和坑爹的百度多番搜索无果,最后的解决办法如下:
    打开项目下的 app/config/middleware.config.js

    module.exports = {
        
        session: {
            key: 'koahub.js'
        },
    
        static: {
            dir: './www',
            dynamic: true
        }
    }
    

    替换成

    module.exports = {
    
      'koa-session2': {
        key: 'koahub.js'
      },
    
      'koa-static-cache': {
        dir: './www',
        dynamic: true
      }
    }
    

    问题就解决了

    相关文章

      网友评论

          本文标题:koahub-wemall 发生报错 Error: The se

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