每当我本地打开 safiri 的时候,本地的 koa 项目就会崩溃,不知道是啥情况。。
Listening on:8000
/Users/lmn/project/u-pain-i-guess/node_modules/koa/lib/application.js:133
const onerror = err => ctx.onerror(err);
^
TypeError: ctx.onerror is not a function
at Array.onerror (/Users/lmn/project/u-pain-i-guess/node_modules/koa/lib/application.js:133:34)
at listener (/Users/lmn/project/u-pain-i-guess/node_modules/on-finished/index.js:169:15)
at onFinish (/Users/lmn/project/u-pain-i-guess/node_modules/on-finished/index.js:100:5)
at callback (/Users/lmn/project/u-pain-i-guess/node_modules/ee-first/index.js:55:10)
at ServerResponse.onevent (/Users/lmn/project/u-pain-i-guess/node_modules/ee-first/index.js:93:5)
at emitNone (events.js:91:20)
at ServerResponse.emit (events.js:188:7)
at onFinish (_http_outgoing.js:592:10)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
上面这串是报错信息,server listen 在 8000 端口
我尝试在代码里进行添加
app
.use(bodyParser)
.use(router.routes())
.use(router.allowedMethods())
.on('error', console.error)
app.onerror = console.error
仍然这样。。
求大大解答。
bodyParser用法错误
替换为