3
votes

Here is the code of my index.html:

<html>
  <head>
    <meta charset="UTF-8" >
    <title>Index</title>
    <link rel="stylesheet" href="styles/main.css" />
    <link rel="stylesheet" ng-href="bower_components/bootstrap/dist/css/bootstrap.min.css" />
 </head>
 <body ng-app="app">


    <div ng-view></div>

    <script src="bower_components/angular/angular.min.js"></script>
    <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="bower_components/angular-route/angular-route.min.js"></script>
    <script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
    <script src="scripts/angular/app.js"></script>
    <script src="scripts/angular/controllers.js"></script>
 </body>
</html>

However, it shows the error in return:

bootstrap.min.js:1 Uncaught SyntaxError: Unexpected token <

ui-bootstrap-tpls.min.js:1 Uncaught SyntaxError: Unexpected token <

bootstrap_error

Is it the problem of my code or bootstrap? I found the error exists when I add

<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> 

and

<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script> 

into the index.html. Does anyone know the cause of the error? Thanks :)

2
Have you looked inside the files? Is there something wrong with them? - Hubert Grzeskowiak
Your webserver is most likely returning a default error message, which is in html. Probably a 404. - tcooc
Can you download the JS files by the given URLs using a browser? I think @tcooc is right. That's a HTML response from the server. - Hubert Grzeskowiak
You say "it shows an error". What is showing an error? When is this error shown? If it is your development environment, you can probably safely configure your development environment to ignore this error. - BPS
Thanks you guys, it is the problem of bootstrap.min.js. A whole set of HTML is stored inside the js while the bootstrap is retrieved from bower.... - seeseesky

2 Answers

2
votes

Its definitely a problem with the bootstrap file. The line 1 contains '<'.

Try manually opening the files and removing it.

1
votes

I was getting the same issue with the ASP.Net. All I had to do is to clean the solution and rebuild it.