每當我本地開啟 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
仍然這樣。 。
求大答案。
你應該把app.js裡的程式碼拿出來看看的,不然誰也無法直接定位問題所在,你這種報錯,可能是中間某段邏輯重寫了app.context。