Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable error display on browser sreen #522

Closed
craigcosmo opened this issue Jul 7, 2016 · 13 comments
Closed

How to enable error display on browser sreen #522

craigcosmo opened this issue Jul 7, 2016 · 13 comments
Labels

Comments

@craigcosmo
Copy link

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

@SpaceK33z
Copy link
Member

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.

@SpaceK33z
Copy link
Member

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

@craigcosmo
Copy link
Author

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

@SpaceK33z
Copy link
Member

create-react-app actually implemented exactly what you want two days ago: facebook/create-react-app#744. You could copy the code from there.

@lalitkapoor
Copy link

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'
    ]
  },

@SpaceK33z
Copy link
Member

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

@mikeaustin
Copy link

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
  }
}

@craigcosmo
Copy link
Author

craigcosmo commented Oct 18, 2017

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

@mikeaustin
Copy link

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.

@mikeaustin
Copy link

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

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

etc...

@JerryChin
Copy link

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

@duartealexf
Copy link

duartealexf commented May 22, 2019

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

@dfontenot
Copy link

For anyone with webpack 5.75.0 that is trying to enable / disable this feature:

devServer: {
  client: {
    overlay: false
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants