Unexpected token < - missing file lib/angular2-modal/plugins/bootstrap.js

362 views
Skip to first unread message

Navaneetha Krishnan S

unread,
Jun 13, 2017, 9:55:39 PM6/13/17
to Angular and AngularJS discussion

I am working on angular2-modal popup, after compiling when I try to launch the application I am getting this error in browser console,

Error: SyntaxError: Unexpected token <
        at eval (<anonymous>)
        at Object.eval (http://localhost:49928/app/AppModule.js:13:19)
        at eval (http://localhost:49928/app/AppModule.js:110:4)
        at eval (http://localhost:49928/app/AppModule.js:111:3)
    Evaluating http://localhost:49928/lib/angular2-modal/plugins/bootstrap.js
    Evaluating http://localhost:49928/app/AppModule.js
    Evaluating http://localhost:49928/app/main.js
    Error loading http://localhost:49928/app/main.js

When I verified this path, there is no file with name bootstrap.js under plugins folder, why is it referring to this file?

Evaluating http://localhost:49928/lib/angular2-modal/plugins/bootstrap.js

What is the mistake I am doing here?

SystemJS.Config.js file is as below

(function (global) {
    System.config({
        paths: {
            'npm:': 'lib/'
        },
        map: {
            app: 'app',
            // angular bundles
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
            '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
            '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
            '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
            '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
            // other libraries
            'rxjs': 'npm:rxjs',
            'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
            'angular2-modal': 'npm:angular2-modal'
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            app: {
                main: './main.js',
                defaultExtension: 'js'
            },
            rxjs: {
                defaultExtension: 'js'
            },
            'angular2-in-memory-web-api': {
                main: './index.js',
                defaultExtension: 'js'
            },
            'angular2-modal': {
                main: 'bundles/angular2-modal.umd',
                defaultExtension: 'js',
            }
        }
    });
})(this);

My package.json

"dependencies": {
    "@angular/common": "~4.1.1",
    "@angular/compiler": "~4.1.1",
    "@angular/core": "~4.1.1",
    "@angular/forms": "~4.1.1",
    "@angular/http": "~4.1.1",
    "@angular/platform-browser": "~4.1.1",
    "@angular/platform-browser-dynamic": "~4.1.1",
    "@angular/router": "~4.1.1",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.6",
    "angular-in-memory-web-api": "~0.3.0",
    "systemjs": "0.19.40",
    "bootstrap": "3.3.7",
    "core-js": "^2.4.1",
    "rxjs": "5.0.1",
    "zone.js": "^0.8.4",
    "angular2-modal": "2.0.3"
  },
  "devDependencies": {
    "concurrently": "^3.2.0",
    "lite-server": "^2.2.2",
    "typescript": "~2.1.0",

    "canonical-path": "0.0.2",
    "tslint": "^3.15.1",
    "lodash": "^4.16.4",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~4.0.14",
    "rimraf": "^2.5.4",

    "@types/node": "^6.0.46",
    "@types/jasmine": "2.5.36"
  }

AppModule.ts

import { NgModule, ErrorHandler }         from '@angular/core';
import { BrowserModule }    from '@angular/platform-browser';
import { FormsModule }      from '@angular/forms';
import { HttpModule }       from '@angular/http';
import { NgbModule }        from '@ng-bootstrap/ng-bootstrap';

import { ModalModule } from 'angular2-modal';
import { BootstrapModalModule } from 'angular2-modal/plugins/bootstrap';
import { Overlay, overlayConfigFactory } from 'angular2-modal';
import { Modal } from 'angular2-modal/plugins/bootstrap';
import { DialogRef, ModalComponent, CloseGuard } from 'angular2-modal';
import { BSModalContext } from 'angular2-modal/plugins/bootstrap';
...

@NgModule({
    imports:
    [
        BrowserModule,
        FormsModule,
        HttpModule,
        ModalModule.forRoot(),
        BootstrapModalModule,
        LOGIN_ROUTER_PROVIDERS
    ],
    declarations:
    [
        AppLoader,
        Login,
        Home,
        ..
    ],
    providers:
    [
        ..
        {
            provide: ErrorHandler, useClass: CustomErrorHandler
        }
    ],
    entryComponents:
    [
        ..
        StoryBook, AddStoryBook
    ],
    bootstrap: [AppLoader]
})

export class AppModule { }

Sander Elias

unread,
Jun 14, 2017, 2:41:38 AM6/14/17
to Angular and AngularJS discussion
Probably one of your templates has a syntax error. Try the AOT compiler, it gives a more clear error during compilation.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages