Express.js,Node.js,EJS - Uncaught SyntaxError:意外的令牌<

时间:2014-10-07 11:26:25

标签: node.js express ejs

1)我的索引页面有ejs:

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

2)我的布局页面有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)我的脚本页面包含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>

但是,我始终会为每个脚本标记收到此错误:

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

将它们更改为cdn位置虽然有效,但这不是我想要的。

1 个答案:

答案 0 :(得分:5)

我想如果我把它包含在我的server.js中会有所帮助:;)

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