Webpack-dev-server: How to enable error display on browser sreen

Created on 7 Jul 2016  路  12Comments  路  Source: webpack/webpack-dev-server

I'd like to show script errors like the screenshot below. Is there a way to do it with webpack devserver

screen shot 2016-07-07 at 2 14 25 pm

Here is my webpack config

entry: './app/index.js',
    output: {
        filename: 'bundle.js',
        path: path.join(__dirname, buildFolder),
        publicPath: publicPath
    },
    devServer: {
        contentBase: buildFolder
    }

Here is I start the dev server:
webpack-dev-server --inline --hot

question

Most helpful comment

Note that since v2.3.0, you can use overlay: true in your devServer config. This is essentially the same as react-dev-utils.

All 12 comments

If you use http://localhost:7770, you'll get those errors like that. It means the app itself will be in an iframe though.

If you want to build this in your app, take a look at #542.

I'm closing this issue because of inactivity. Feel free to comment, and we can always re-open it again.

I don't see how the reference #542 suggest a solution for this issue. Unless I don't understand it correctly.

create-react-app actually implemented exactly what you want two days ago: https://github.com/facebookincubator/create-react-app/pull/744. You could copy the code from there.

you can add react-dev-utils to your package.json and then add 'react-dev-utils/webpackHotDevClient' to your entry (before your app's starting point) - e.g.:

entry: {
    'app': [
      'react-hot-loader/patch',
      'react-dev-utils/webpackHotDevClient',
      './public/index.js'
    ]
  },

Note that since v2.3.0, you can use overlay: true in your devServer config. This is essentially the same as react-dev-utils.

overlay: true doesn't seem to do anything for me. Am I doing something wrong?

"webpack-dev-server": "^2.9.2"

module.exports = {
  ...
  devServer: {
    overlay: true
  }
}

overlay: true does work for me. Not all errors will be shown as overlay

I have seen in rare occurrences. I thought it would be shown for all and any errors, but that doesn't seem to be the case.

Ahh, it doesn't seem to capture runtime errors...?

"Uncaught ReferenceError: x is not defined"
"Uncaught TypeError: window.foo is not a function"

etc...

Can't capture runtime errors, what a big disappointment.

That does not make sense, of course it should not capture runtime errors!
What are try/catch blocks for, anyway?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adiachenko picture adiachenko  路  3Comments

antoinerousseau picture antoinerousseau  路  3Comments

eyakcn picture eyakcn  路  3Comments

uMaxmaxmaximus picture uMaxmaxmaximus  路  3Comments

tulika21-zz picture tulika21-zz  路  3Comments