简体   繁体   中英

Angular 2 System src can't find core stuff (without packages)

Have one interesting issue with System.js and Angular 2.

In default quickstart we have this system config:

System.config({
      packages: {
        built: {
          format: 'register',
          defaultExtension: 'js'
        }
      }
    });
    System.import('built/main')
        .then(null, console.error.bind(console));

It's works for me. But now I try to move all files from built upp. So main.js file on one level with index.html. So for now system package can't be deployed. Because thy need some folder name (all node_modules installed correctly on the root folder with all angular2 stuffs).

And I try to use some simple config:

System.config({
       defaultJSExtensions: true
    });
    System.import('main')
        .then(null, console.error.bind(console));

but got many errors like this:

system.src.js:1061 GET http://localhost:3000/angular2/platform/browser.js 404 system.src.js:1061 GET http://localhost:3000/angular2/router.js 404 (Not Found)

http://prntscr.com/ardlin

Thanks for any help!

I think that you forgot to include the Angular2 bundled files:

<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/router.dev.js"></script -->

Because SystemJS can find modules they contain, it tries to load from .js since you set the defaultJSExtensions attribute is set to true in its configuration.

Thierry) you helped me a lot again. Thanks friend :)

Founded one of your oldest answers for simillar issue Angular2 systemjs issues

You are right. We MUST keep all angular js files in some folder. This folder must be placed at the same level with index.html and register it like local package. It's really strange and interesting rule, but whatever.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM