webpack-dev-server: Cannot GET /
- Operating System: Windows 10 x64
- Node Version: 7.3.0
- NPM Version: 3.10.10
- webpack Version: 4.5.0
- webpack-dev-server Version: 3.1.3
- This is a bug
- This is a modification request
Code
https://github.com/MitchTalmadgeUofU/Digital-Story/tree/a73fbbf8c5d0f90d9190232e976407610eb5fb7e
Expected Behavior
When I visit http://localhost:9000/
, it should display the index.html page generated by HtmlWebpackPlugin.
Actual Behavior
When I visit http://localhost:9000/
, I receive a 404: Cannot GET /
. If I compile the index.html using my production webpack config – so that the files are generated on the hard drive and not in memory – I can then load webpack dev server and the index.html file is served (but does not update when I make changes to the template).
For Bugs; How can we reproduce the behavior?
- Clone the repository
- Edit: We discovered that this error only occurs on Windows, and only if you clone into a directory with spaces in the path. No spaces? No error.
- Checkout this tree:
git checkout a73fbbf8c5d0f90d9190232e976407610eb5fb7e .
- Install dependencies:
npm i
- Start dev-server:
npm run dev-web
.
- Edit: I forgot to remove part of my
dev-web
script; openpackage.json
and replace thedev-web
script contents with:
webpack-dev-server --config webpack/webpack.dev.config.js --progress
- Visit http://localhost:9000 and see the error message.
- Stop the dev-server.
- Compile the production files:
npm run build-web
. - Start dev-server again:
npm run dev-web
. - Visit http://localhost:9000 and see “Hello World”.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 26
- Comments: 32 (1 by maintainers)
As far as I’m concerned I’ve fixed the issue by
The problem is resolved. The issue was with the directory name. For the output, I was using “output” directory and for devServer I was providing contentBase from “dist” which was not containing index.html page. So it was throwing “Cannot Get /” error
ok i got this - thanks to this issue - https://github.com/webpack/webpack-dev-server/issues/1375 for now - you need remove spaces from the project path
@MitchTalmadgeUofU you can use the following versions; these are the last ones that worked for me:
I receive
Cannot GET /
on Windows for all versions which are higher than 3.1.0.Is this related? https://github.com/webpack/webpack-dev-middleware/issues/270
@ejnu I can confirm, the problem is solved by removing spaces from the path. Particularly, the
contentBase
is what must have no spaces in the path.It is quite clear this is a webpack-dev-middleware bug, so everyone please follow this issue until it is fixed, then we can update the dependency in this repository after a fix is released:
https://github.com/webpack/webpack-dev-middleware/issues/296
This is the key
@nguyenkhois I have tried that also but still getting the same error. I am using Windows 8.1
the setup bellow works for me as expected for quite some time by now…
webpack.config.js
webpack.dev.js
index.html
@nguyenkhois I had the same issue, upgraded to 3.1.4, and it has been fixed! Thanks!
This issue has been fixed in version 3.1.4. It works finne for me now 👍 Thanks so much! 🥇
However Webpack Dev Middleware issue still persists, only Version of 3.0.1 for Webpack Dev Middleware works, below(MIME type issue) or above(Cannot GET /) all fails.
I also have the same problem that only appears on Windows, but on Mac and Ubuntu, it works fine.