TypeError: Array.from is not a function

I follow Angular.io documenation to write a simple "Hello World" application with Angular 2. Once the application runs in the browser, Angular 2 throws a TypeErrorout of angular2/src/browser_adapter.js.

Everything seems to be set up correctly. Think what the problem is?

Console:

TypeError: Array.from is not a function
    at createArrayFromMap (http://localhost:3000/node_modules/angular2/src/facade/collection.js:61:42)
    at Function.MapWrapper.values (http://localhost:3000/node_modules/angular2/src/facade/collection.js:100:47)
    at _createListOfBindings (http://localhost:3000/node_modules/angular2/src/di/injector.js:769:36)
    at Function.Injector.resolve (http://localhost:3000/node_modules/angular2/src/di/injector.js:403:16)
    at Function.Injector.resolveAndCreate (http://localhost:3000/node_modules/angular2/src/di/injector.js:420:41)
    at _createAppInjector (http://localhost:3000/node_modules/angular2/src/core/application_common.js:291:39)
    at http://localhost:3000/node_modules/angular2/src/core/application_common.js:257:31
    at Zone.run (http://localhost:3000/node_modules/angular2/bundles/angular2.js:118:17)
    at Zone.run (http://localhost:3000/node_modules/angular2/src/core/zone/ng_zone.js:165:42)
    at NgZone.run (http://localhost:3000/node_modules/angular2/src/core/zone/ng_zone.js:112:40)BrowserDomAdapter.logError @ :3000/node_modules/angular2/src/dom/browser_adapter.js:71

all.babel.js (runs for es5 all.js):

import {Component, View, bootstrap} from 'angular2/angular2'

@Component({
  selector: 'helloworld'
})
@View({
  template: `<h1>Hello World!</h1>`
})
class HelloWorld {

}


bootstrap(HelloWorld)

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Angular 2 Hello World</title>
    <script src="./node_modules/rx/dist/rx.all.js" charset="utf-8"></script>
    <script src="./node_modules/systemjs/dist/system.js"></script>
    <script src="./node_modules/angular2/bundles/angular2.js" charset="utf-8"></script>
    <script src="./dist/all.js" charset="utf-8"></script>
  </head>
  <body>
    <helloworld></helloworld>
     <script type="text/javascript">
      System.config({
        baseURL: '/'
      , defaultJSExtensions: true
      , paths:  {
          'angular2/*': './node_modules/angular2/*.js' // Angular
        , 'rx': './node_modules/rx/dist/rx.all.js'
        , 'all': './dist/all.js'
        }
      })

      System.import('all')
    </script>
  </body>
</html>

Replicate https://github.com/agconti/angular-2-hello-world .

+4
source share
1 answer

To run Angular 2 in a browser, I had to enable tracer runtime:

<script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script>

, System.js Babel .

+7

Source: https://habr.com/ru/post/1605805/


All Articles