Skip to content
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

"Unexpected token <" when loading socket.io.js locally #839

Closed
zappfinger opened this issue May 14, 2015 · 5 comments
Closed

"Unexpected token <" when loading socket.io.js locally #839

zappfinger opened this issue May 14, 2015 · 5 comments

Comments

@zappfinger
Copy link

When I load the client library as follows:

<script src="js/socket.io.js"></script>

I get the above error.
It points to line 4 in the file, that starts with:

I already have defined this line earlier, could that be the problem?

Richard

@zappfinger
Copy link
Author

src="js/socket.io.js"

@nkzawa
Copy link
Contributor

nkzawa commented Jan 16, 2016

It has to be src="/socket.io/socket.io.js"

@nkzawa nkzawa closed this as completed Jan 16, 2016
@barbalex
Copy link

barbalex commented Dec 8, 2016

I get the same error using this html file:

<!doctype html>
<html lang="en">
<head>
  <!-- The first thing in any HTML file should be the charset -->
  <meta charset="utf-8">
  <!-- Make the page mobile compatible -->
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Allow installing the app to the homescreen -->
  <link rel="manifest" href="manifest.json">
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.css">
  <meta name="mobile-web-app-capable" content="yes">
  <title>AP Flora</title>
</head>
<body>
<!-- The app hooks into this div -->
<div id="app"></div>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- A lot of magic happens in this file. HtmlWebpackPlugin automatically includes all assets (e.g. bundle.js, main.css) with the correct HTML tags, which is why they are missing in this HTML file. Don't add any assets here! (Check out webpackconfig.js if you want to know more) -->
<script src="/socket.io/socket.io.js"></script>
<script>
  const socket = io()
  console.log(`socket:`, socket)
</script>
</body>
</html>

What am I doing wrong?

@barbalex
Copy link

barbalex commented Dec 8, 2016

it works when I use:

<script src="https://cdn.socket.io/socket.io-1.4.0.js"></script>

Wo what is the correct url?

@moreirapontocom
Copy link

Calling socket.io.js locally, it worked when I use browserify to compile the correct required files. Another way is use the lib inside socket.io-client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants