Webpack-dev-server: "Syntax error: Unexpected token <" with webpack-dev-server and HotModuleReplacingPlugin

Created on 23 Mar 2015  路  10Comments  路  Source: webpack/webpack-dev-server

Duplicating https://github.com/babel/babel-loader/issues/43 here too, 'cause I really cannot figure out what's causes that issue and it looks like webpack's stuff.

Most helpful comment

<script src="/bundle.js"></script> not <script src="bundle.js"></script>

All 10 comments

Can you compare your setup with https://github.com/gaearon/react-hot-boilerplate?

@gaearon I did it.. The only difference is that I'm using CLI instead of Node.js API.

@gaearon @sokra demo repo with reproducible bug might help - https://github.com/voronianski/webpack-trouble-demo

I just realized you have two servers. Here's _what I guess_ to be your problem: your app runs on other port than WebpackDevServer but the publicPath is /build/, so Webpack runtime requests hot updated script at /build/, which is served by your Express app.

Setting publicPath explicitly to http://localhost:8080/build/ should help. I think there's also some other more idiomatic way of doing this but this is what I can help with.

@gaearon yep, setting publicPath explicitly to http://localhost:8080/build/ solved this error :+1:

@gaearon thanks! Probably now issue can be closed.

<script src="/bundle.js"></script> not <script src="bundle.js"></script>

@voronianski , I got the similar issue on production, I don't think the same approach works here for me. Any help?

My html page looks like below.

<!doctype html>
<html lang=en>

<head>
    <title>My Site</title>
    <meta charset=utf-8>
    <meta name=viewport content="width=device-width,initial-scale=1">
</head>

<body>
    <div id=root style="height: 100%">
        <h4 style="text-align: center" class=loader>Page is loading...</h4>
    </div>
    <script type=text/javascript src=/assets/js/manifest.60b7f228ef509010b4c4.js></script>
    <script type=text/javascript src=/assets/js/vendor.60b7f228ef509010b4c4.js></script>
    <script type=text/javascript src=/assets/js/app.60b7f228ef509010b4c4.js></script>
</body>

</html>

I had to delete the bundled file after everything else and rerun the build, if anyone else is experiencing issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jack-Works picture Jack-Works  路  3Comments

mischkl picture mischkl  路  3Comments

antoinerousseau picture antoinerousseau  路  3Comments

MJ111 picture MJ111  路  3Comments

mrdulin picture mrdulin  路  3Comments