Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including egg-error-display with all npm packages installed. Try it out:

var eggErrorDisplay = require("egg-error-display")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

egg-error-display v1.5.7

Allow customize the default egg-onerror's definition of isProd (线上 !== 生产)


Allow customize the default egg-onerror's definition of isProd (线上 !== 生产)

NPM version Build Status Build status codecov David deps Known Vulnerabilities npm download

Quality gate


egg 项目本地跑起来后,如果有报错,会展示非常详细的错误堆栈。但是一旦发布到线上,就只会显示一个出错了,但是具体信息被隐藏了。

原因是 egg 默认的错误处理插件 egg-onerror 只对 app.envlocal 或者 unittest 的情况展示详细信息,其他环境都被认为是生产环境,所以隐藏了错误堆栈。(了解更多



  • 允许自定义 isProd 函数,用来确定当前 app 是否是生产环境。


$ npm i egg-error-display --save


  1. Enable it on plugin configuration:
// {app_root}/config/plugin.[t|j]s
exports.onError = {
  enable: true,
  package: "egg-error-display"
  1. Configure the isProd function:
// {app_root}/config/config.default.[t|j]s
exports.onError = {
    isProd: (app: Application) => app.env === 'prod'

see config/config.default.ts for more detail.

Questions & Suggestions

Please open an issue here.




npm run test-local

Release Notes:

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free