-
-
Notifications
You must be signed in to change notification settings - Fork 376
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
[HMR] Update check failed: SyntaxError: Unexpected token < #68
Comments
This also seems to be a bit random. Sometimes I get the error, sometimes it works as expected. It also seems to happen more often if my initial change is in particular files, especially an imported css file. However, these files do hot reload if my initial change does not cause an error. |
I'm trying to narrow this down... This seems to be what is happening when HRM does not work:
When HRM does work the exact process as above takes place, but middleware receives the correct hash for the hot-update.json file, and therefore finds it, handles it and sends a response. As I said before, it seems to be a bit random as to when it does and does not work. What could be the possible reasons that the middleware receives the incorrect hash? |
I'm encountering pretty much the same problem. Has anyone managed to find a solution? |
I have an issue like this and fixed with: Webpack don't find the right place to find manifest, or it arrives wrong... |
@colinmeinke how did you get it working? can I am having the same problem and stuck with it. |
publicPath can be just '/'
|
Closing, because the documentation also makes clear that |
@colinmeinke, you need to use a full URL for HRM:
|
Full URL seems unnecessary; a valid URL that starts with
|
|
I'm stuck on the same issue but nothing from above could fix it. Any solutions? |
in you server.js
|
FYI for anyone having issues with this in combination with the vue-cli templates.. I ended up having to add a resolve alias to the webpack configuration to get everything working reliably: resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'socket.io-client$': 'socket.io-client/dist/socket.io.js',
'@': resolve('src')
}
}, |
I am getting this error when I am using webpack 4 with browser-sync even though my publicPath is setup, I am getting this weard hot update on each page reload that simply contains html representation of the page openned. Here is my config
This is my webpack config
Was working fine with webpack 3... |
I had to delete my bundled file after everything else and then rerun the build, if anyone is still hitting issues. |
For issue theme's this solution is worked for me. In your
I think cause middleware+hot-middleware works like webpack-dev-server and it does not need any additional static files. Also I deleted |
I ran into this issue and wrestled with (and beat!) it today -- this is the top Google result for the error message in the subject line, so I thought I might shed some additional light on this for those that happen to land here. The error message is happening because of this code that webpack injects in your client bundle: request.onreadystatechange = function() {
if (request.readyState !== 4) return;
if (request.status === 0) {
// timeout
reject(
new Error("Manifest request to " + requestPath + " timed out.")
);
} else if (request.status === 404) {
// no update available
resolve();
} else if (request.status !== 200 && request.status !== 304) {
// other failure
reject(new Error("Manifest request to " + requestPath + " failed."));
} else {
// success
try {
var update = JSON.parse(request.responseText);
} catch (e) {
reject(e);
return;
}
resolve(update);
}
} The HMR module is trying to look for an update JSON manifest, and when there's none available, your server should be returning a 404 or 500. What's causing this error is that your server is returning a 200/304 and, perhaps, some default html (hence the 'unexpected token <') when it's expecting JSON. For me at least, this was caused by not handling 404 errors properly in my Express app -- I was testing HMR before I was ready to :) So make sure you're returning proper error codes for asset files in your publicPath and you should be good! |
Finally I found the solution for this error just change, To app.get('/', (req, res) => { It works to me |
I opened my local url with: This caused the error. |
This worked for me too. Thanks so much! |
I'm having an issue with hot module reloading on this repo.
I receive the following error:
The error comes from within
hotDownloadManifest
. Therequest.responseText
is HTML, rather than the usual json. This gets passed intoJSON.parse
which throws. I cannot work out whyresponseText
is HTML.This repo has a fair amount of CSS split into different files. If I remove a few on the CSS imports it works (most of the time), so my best guess is that it's something to do with a file limit. Could this be the case?
The text was updated successfully, but these errors were encountered: