PatrickJS-starter icon indicating copy to clipboard operation
PatrickJS-starter copied to clipboard

Error on refresh

Open daniel7912 opened this issue 10 years ago • 14 comments

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!

daniel7912 avatar Sep 26 '16 13:09 daniel7912

+1

fmoessle avatar Sep 26 '16 22:09 fmoessle

Try removing completely useHash

aminebizid avatar Sep 27 '16 05:09 aminebizid

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) { %>

noorahmed94 avatar Sep 27 '16 07:09 noorahmed94

Im getting the same problem, when HMR reloads the page on non-root (e.g. http://localhost:3000/help) it just shows these tags.

DanielMcAssey avatar Sep 27 '16 08:09 DanielMcAssey

@zigzag95 changing RouterModule.forRoot(ROUTES, { useHash: true }), to RouterModule.forRoot(ROUTES) did not solve my problem

fmoessle avatar Sep 27 '16 08:09 fmoessle

Tried the same fix as @fmoessle and updating to the latest Node v6.6.0, still not working.

DanielMcAssey avatar Sep 27 '16 09:09 DanielMcAssey

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 avatar Sep 27 '16 09:09 fmoessle

fmoessle this worked

wilfredmifsud avatar Sep 28 '16 08:09 wilfredmifsud

@fmoessle that fix worked for me. Thanks

DanielMcAssey avatar Sep 29 '16 08:09 DanielMcAssey

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.

semocodev avatar Sep 30 '16 14:09 semocodev

you can also try this fantastic repo with Universal, WebpackBeta25, AOT, and Angular 2.0.1 https://github.com/qdouble/angular2webpack2-starter

fmoessle avatar Sep 30 '16 15:09 fmoessle

Please, Help! Haven't this been fixed yet? Im facing the same problem, I have webpack-dev-server : 2.1.0-beta11

theRaffe avatar Dec 01 '16 22:12 theRaffe

Same problem.

"webpack": "2.1.0-beta.27",
"webpack-dev-middleware": "1.6.1",
"webpack-dev-server": "2.1.0-beta.6",

LehaMotovilov avatar Dec 16 '16 15:12 LehaMotovilov

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/)

lucaritossa avatar Apr 13 '17 16:04 lucaritossa