Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webpack-dev-server opens localhost:8080/undefined

When I run $ npm run dev ("dev": "webpack-dev-server") it opens localhost:8080/undefined instead of localhost:8080 or at least localhost:8080/index.html

webpack-config.js devServer part:

devServer: {

    contentBase: path.join(__dirname, 'dist'),

    compress: true,

    stats: "errors-only",

    hot: true,

    open: true

If I delete the /undefined part of the URL it works properly even the hot module replacement so it's not a big problem; just want to know why is that happening.

Edit: Im on MacOS

Edit2: Console info when npm run dev:

Project is running at http://localhost:8080/ webpack output is served from / Content not from webpack is served from /Users/cozarkd/folders/dist webpack: wait until bundle finished: /undefined webpack: Compiled successfully.

Ty

like image 713
Diego de Sousa Avatar asked Jul 05 '17 10:07

Diego de Sousa


People also ask

What is the default port for Webpack dev server?

webpack-dev-server on port 8080 .

What is Webpack dev server in angular?

Webpack is a popular module bundler, a tool for bundling application source code in convenient chunks and for loading that code from a server into a browser. It's an excellent alternative to the SystemJS approach used elsewhere in the documentation.

How do I find the Webpack dev server file?

You can check which files are being served by the dev server by going to /webpack-dev-server route. For example, localhost:9000/webpack-dev-server.


1 Answers

This seems to be caused by a bug: https://github.com/webpack/webpack-dev-server/issues/960

A quick workaround is offered (here):

devServer: {
  contentBase: path.join(__dirname, 'dist'),
  compress: true,
  stats: "errors-only",
  hot: true,
  open: true,
  openPage: '' // <-- this
}
like image 137
robertklep Avatar answered Oct 13 '22 11:10

robertklep