deeleman / learning-angular2

Code samples repository for the examples provided in "Learning Angular 2", published by Packt Publishing - THE BOOK COVERS UP TO RC.1 and hence is severely OUTDATED. PLEASE REFER TO THE LATEST EDITIONS INSTEAD.
https://www.packtpub.com/web-development/learning-angular-2
108 stars 59 forks source link

System.Import is not a function Error. #26

Closed RichLinnell closed 8 years ago

RichLinnell commented 8 years ago

Hi,

I've followed the book almost to the letter, deviating only slightly to skirt around a small coding issue in index.html that had no open script tag and now when I try to run the Hello Angular I am getting the following error

(index):15 Uncaught TypeError: System.Import is not a function(anonymous function) @ (index):15

The system.js script is definitely being loaded, chrome is not giving any errors (if I deliberately misname the system.js src it does give an error).

Any pointers greatly appreciated.

deeleman commented 8 years ago

Since SystemJS is loaded as a global dependency in the global scope, you can check by your self if the whole object is available and hence if the System.import() function is accessible, by inspecting both from the Dev Tools. Just open your app and type System and System.import (take advantage of the auto-complete features for this) to see if you get an output like this:

console

If not, please make sure that your node_modules folder contains all the required SystemJS files and the also check your <script> blocks are in the right order.

Do you get the same error when downloading and building the code from this repo?

RichLinnell commented 8 years ago

Hi Pablo,

Sorted it out. I had mistakenly typed

<script> 
  System.Import('built/hello-angular');
</script>

instead of

<script> 
  System.import('built/hello-angular');
</script>

Sorry for wasting your time. Your pointer about using the immediate tools in the browser pointed me in the right direction.

deeleman commented 8 years ago

Thanks for letting me know. It is always a pleasure to help.

Hope you're enjoying the book. :)