McFarlane
McFarlane

Reputation: 1877

JavaScript causes error on nodeJS server

I am trying to run a nodeJS test script with socket.io but the deployed script on my server causes an error if I am trying to include any javascript.

Just calling the HTML via nginx on my localhost does not throw any error.

this is my index.html:

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="UTF-8" />
    <title>NodeJS Realtime Test</title>
    <script type="text/javascript" src="/client/app.js"></script>
</head>
<body>
    <p>Moin!</p>
</body>
</html>

and this is the content of the app.js:

console.log("test");

Chrome throws me this error:

Uncaught SyntaxError: Unexpected token < app.js:1

In Opera, the error is:

Syntax error at line 1 while loading: expected expression, got '<'  Linked script compilation   app.js

also, the debugger shows that the error occurs on char one of my index.html file. what am I missing here?

Upvotes: 1

Views: 3459

Answers (1)

McFarlane
McFarlane

Reputation: 1877

Thanks to the comment of Jani Hartikainen I recognized that it was a misconfiguration of the nodeJS server.

The example I used served index.html on any request on the server. It works using this configuration: https://gist.github.com/701407

Upvotes: 1

Related Questions