JS does not load modules

I have a strange problem with System JS when I play with Angular 2.

Everything has been working fine for a while, but a seemingly random JS system can no longer find modules ...

I get this error message:

GET http://localhost:9000/angular2/platform/browser.js 404 (Not Found) @ system.src.js:4891(anonymous function) @ system.src.js:4891
GET http://localhost:9000/angular2/core.js 404 (Not Found) @ system.src.js:4891
GET http://localhost:9000/angular2/router.js 404 (Not Found) @ system.src.js:4891
GET http://localhost:9000/angular2/http.js 404 (Not Found) @ system.src.js:4891
GET http://localhost:9000/angular2/core.js 404 (Not Found) @ system.src.js:4891
GET http://localhost:9000/angular2/http.js 404 (Not Found) @ system.src.js:4891
GET http://localhost:9000/angular2/src/facade/lang.js 404 (Not Found) @ system.src.js:4891
GET http://localhost:9000/angular2/router.js 404 (Not Found) @ system.src.js:4891

Sometimes sometimes it’s less mistakes ...

The strangest thing is that after waiting and re-refreshing the page, the application starts working again!

I am using systemjs@0.19.20 and angular2 @ 2.0.0-beta.3 (the latter at that time).

The script section of index.html with the SystemJS configuration is as follows:

<script src="./node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="./node_modules/es6-shim/es6-shim.min.js"></script>
<script src="./node_modules/systemjs/dist/system.js"></script>
<script>
  //configure system loader
  System.config({
    defaultJSExtensions: true
  });
  //bootstrap the Angular2 application
  System.import('dist/app').catch(console.log.bind(console));
</script>
<script src="./node_modules/rxjs/bundles/Rx.js"></script>
<script src="./node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="./node_modules/angular2/bundles/http.dev.js"></script>
<script src="./node_modules/angular2/bundles/router.dev.js"></script>

Has anyone recognized this problem?

Thanks!

+4
source share
2 answers

, SystemJS :

- HTML:

<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/router.dev.js"></script>
<script src="node_modules/angular2/bundles/http.dev.js"></script>

<script>
  System.config({
    packages: {        
      app: {
        format: 'register',
        defaultExtension: 'js'
      }
    }
  });
  System.import('app/boot')
        .then(null, console.error.bind(console));
</script>

, HTTP-, , SystemJS - :

  System.config({
    packages: {        
      app: {
        format: 'register',
        defaultExtension: 'js'
      },
      angular2: {
        format: 'register',
        defaultExtension: 'js'
      }
    }
  });
0

, , . , app.ts dist/app?

0

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


All Articles