Express.js, Node.js, EJS - Uncaught SyntaxError: Unexpected token <

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) Page of my scripts 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 get this error for each of the script tags:

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

      

Changing them in the cdn location works, but that's not what I want.

+3


source share


1 answer


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



  ....
  , path = require('path'),
  .....
  app.use(express.static(path.join(__dirname, 'public')));

      

+5


source







All Articles