3

1) My index page with ejs:

 <%include ../includes/layout.ejs %>
 <h1>This is the index page, did layout come along?</h1>

2) My layout pages with ejs:

 <!DOCTYPE html> <html>
 <head>
    <title>MultiVision</title> 
    <% include ../includes/styles.ejs %>
    <script type="text/javascript" rc="/vendor/jquery/dist/jquery.min.js"></script>
</head>
<body>
  <%include ../includes/scripts.ejs%>
</body> 
</html>

3) My scripts page with ejs:

 <script src="/vendor/bootstrap/dist/js/bootstrap.js" type="text/javascript"></script> 
 <script src="/vendor/toastr/toastr.js" type="text/javascript"></script>
 <script src="/vendor/angular/angular.js"type="text/javascript"></script> 
 <script src="/vendor/angular-resource/angular-resource.js" type="text/javascript"></script> 
 <script src="/vendor/angular-route/angular-route.js" type="text/javascript"></script> 
 <script src="/app/app.js" type="text/javascript"></script>

However, I consistently receive this error for each of the script tags:

Uncaught SyntaxError: Unexpected token <  ######.js

Changing them to a cdn location works though, but that is not what I want.

1 Answer 1

6

I guess it would help if I had included this in my server.js: ;)

  ....
  , path = require('path'),
  .....
  app.use(express.static(path.join(__dirname, 'public')));
Sign up to request clarification or add additional context in comments.

3 Comments

I found this helpful and it also fixed my issue. I'm having a hard time understanding why this was needed though?
The *.js files weren't set up to be statically served, and so instead the server was returning a 404 error which the browser tried to parse as JavaScript.
Thanks, was finally able to serve a webpack generated bundle using this statement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.