0

When I try to import the boot.js from a layout page, I keep getting a 404 error. enter image description here

Here is the code I am using to import it:

<!-- Configure SystemJS -->
<script src="/appScripts/config.js"></script>
<script>
        System.import('/appScripts/boot')
              .then(null, console.error.bind(console));
</script>

Here is my folder structure: enter image description here

Everything works fine when I use index.html (seen in wwwroot), but not when I try from /views/shared/_layout.cshtml

Here is my config.js

(function (global) {

    // map tells the System loader where to look for things
    var map = {
        'app': 'appScripts', // 'dist',
        'rxjs': 'libs/rxjs',
        'angular2-in-memory-web-api': 'libs/angular2-in-memory-web-api',
        '@angular': 'libs/@angular'
    };

    // packages tells the System loader how to load when no filename and/or no extension
    var packages = {
        'app': { main: 'boot.js', defaultExtension: 'js' },
        'rxjs': { defaultExtension: 'js' },
        'angular2-in-memory-web-api': { defaultExtension: 'js' },
    };

    var packageNames = [
      '@angular/common',
      '@angular/compiler',
      '@angular/core',
      '@angular/http',
      '@angular/platform-browser',
      '@angular/platform-browser-dynamic',
      '@angular/router',
      '@angular/router-deprecated',
      '@angular/testing',
      '@angular/upgrade',
    ];

    // add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' }
    packageNames.forEach(function (pkgName) {
        packages[pkgName] = { main: 'index.js', defaultExtension: 'js' };
    });

    var config = {
        map: map,
        packages: packages
    }

    // filterSystemConfig - index.html's chance to modify config before we register it.
    if (global.filterSystemConfig) { global.filterSystemConfig(config); }

    System.config(config);

})(this);   

Thank you very much for your help and please let me know if you need more information.

0

1 Answer 1

1

I thought I had tried this, but it is hard to keep track of it all. Here is how I solved this. Notice the baseURL line.

<!-- Configure SystemJS -->
<script>System.config({ baseURL: '/' });</script>
<script src="/appScripts/config.js"></script>
<script>
    System.import('appScripts/boot').catch(console.log.bind(console));
</script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.