0

When i write <base href="/"> in the index.html, then its shows error like (index):21 Uncaught ReferenceError: System is not defined. And if i remove <base href="/"> in index.html then it shows error like core.umd.js:3462 EXCEPTION: Error in ./AppComponent class AppComponent - inline template:3:5 caused by: No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document. enter image description here

Console: enter image description here

enter image description here

Node Modules contains all that files

Ketan Akbari
  • 10,837
  • 5
  • 31
  • 51
  • 1
    Possible duplicate of http://stackoverflow.com/questions/35777642/angularjs-2-with-typescript-referenceerror-system-is-not-defined-system-config – Hardipsinh Jadeja Sep 23 '16 at 06:24

3 Answers3

1

you are already loading system.js from node_modules so you needn't import it from cdn link.

<script src="https://code.angularjs.org/tools/system.js"></script> //<-- comment this out.

alternatively you should trying adding importing APP_BASE_HREF in root module instead of using href.

import {APP_BASE_HREF} from '@angular/common';

@NgModule({
  declarations: [AppComponent],
  imports: [routing /* or RouterModule */], 
  providers: [{provide: APP_BASE_HREF, useValue : '/' }]
]); 

see this answer for more info.

Community
  • 1
  • 1
candidJ
  • 4,289
  • 1
  • 22
  • 32
  • if i do so, it shows `core.umd.js:3427 EXCEPTION: Uncaught (in promise): Error: Cannot match any routes: 'angular2'` and in address bar in shows `http://localhost/` rather than `http://localhost/angular2` – Ketan Akbari Sep 24 '16 at 04:53
0

Most probably you have not added this file in index.html

<script src="https://code.angularjs.org/tools/system.js"></script>

for reference have a look here https://angular.io/guide/quickstart

Evan Wieland
  • 1,445
  • 1
  • 20
  • 36
Pardeep Jain
  • 84,110
  • 37
  • 165
  • 215
0

It looks like you didn't run npm install (assuming that you have package.json). All your errors are about not finding files in node_modules dir in your project.

For a sample project configuration see this sample project: https://github.com/Farata/angular2typescript/tree/master/chapter2/angular-seed

Yakov Fain
  • 11,972
  • 5
  • 33
  • 38