Uncaught SyntaxError: Unexpected token < when using bootstrap js

14,964

Solution 1

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

Try manually opening the files and removing it.

Solution 2

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

Share:
14,964
seeseesky
Author by

seeseesky

Updated on June 30, 2022

Comments

  • seeseesky
    seeseesky almost 2 years

    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 :)

  • seeseesky
    seeseesky over 7 years
    Thanks!! I checked the bootstrap file and found that the index.html code is saved inside...I am now using bootstrap CDN link instead of bootstrap installed from bower and it is now solved. Although I still cannot figure out why index.html code will be saved inside the bootstrap.min.js while it is retrieved from bower...