Error on refresh
The app works great if I leave everything as the default and use npm start, but when I change:
RouterModule.forRoot(ROUTES, {useHash: true}) to:
RouterModule.forRoot(ROUTES, {useHash: false})
I am getting errors on refresh. If I load/refresh the app at http://localhost:3000 it works fine still, but if I try refreshing while I'm one of the other pages, e.g. http://localhost:3000/about then I get this error:
<% if (webpackConfig.htmlElements.headTags) { %> <%= webpackConfig.htmlElements.headTags %> <% } %> Loading... <% if (webpackConfig.metadata.isDevServer && webpackConfig.metadata.HMR !== true) { %> <% } %>
Anyone know how to stop this from happening? Thanks!
+1
Try removing completely useHash
I am facing the same issue with my code. The code runs well but on refresh the application stucks. Somehow webpackConfig is undefined in <% if (webpackConfig.htmlElements.headTags) { %>
Im getting the same problem, when HMR reloads the page on non-root (e.g. http://localhost:3000/help) it just shows these tags.
@zigzag95
changing
RouterModule.forRoot(ROUTES, { useHash: true }),
to
RouterModule.forRoot(ROUTES)
did not solve my problem
Tried the same fix as @fmoessle and updating to the latest Node v6.6.0, still not working.
I changed
"webpack-dev-middleware": "^1.6.1", "webpack-dev-server": "^2.1.0-beta.2",
to
"webpack-dev-middleware": "1.6.1", "webpack-dev-server": "2.1.0-beta.2",
now its working with:
RouterModule.forRoot(ROUTES)
or
RouterModule.forRoot(ROUTES, { useHash: true })
fmoessle this worked
@fmoessle that fix worked for me. Thanks
It seems that,
"webpack-dev-server": ">=2.1.0-beta.6"
breaks the workflow when user accesses from path http://localhost:3000/about without hash strategy as entry point to the app.
you can also try this fantastic repo with Universal, WebpackBeta25, AOT, and Angular 2.0.1 https://github.com/qdouble/angular2webpack2-starter
Please, Help! Haven't this been fixed yet? Im facing the same problem, I have webpack-dev-server : 2.1.0-beta11
Same problem.
"webpack": "2.1.0-beta.27",
"webpack-dev-middleware": "1.6.1",
"webpack-dev-server": "2.1.0-beta.6",
I'm using these packs and I'm facing the same issue...
"webpack": "2.3.1",
"webpack-dev-middleware": "^1.10.0",
"webpack-dev-server": "2.4.1"
I solved putting this option into devServer configuration
historyApiFallback: {
index: '/foo-app/'
},
Please pay attention, I'm also using publicPath because I'm running my app on a custom path, different from '/' (ie: http://localhost:3000/foo-app/)