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.

Scimonster
  • 32,893
  • 9
  • 77
  • 89

1 Answers1

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')));
  • I found this helpful and it also fixed my issue. I'm having a hard time understanding why this was needed though? – bretcj7 Mar 01 '15 at 20:43
  • 2
    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. – cjfont Apr 14 '16 at 21:07
  • Thanks, was finally able to serve a webpack generated bundle using this statement. – Android Noob Aug 27 '16 at 14:45