简体   繁体   中英

Main.js not found (SystemJS, Angular2)

I've been upgrading my Angular2 RC4 app to the RC5 version, and I've suddenly run into this issue.

My app compiles fine, but when I load the page at localhost:3001 , I get a 404 for my main.js .

I'm also using gulp.

This is my file structure:

.
+-- src
|   +-- app
|   |   +-- main.ts
|   |   +-- app.module.js
|   |   +-- app.component.ts
|   |   +-- app.component.html
|   |   +-- components <-- Directory
|   |   +-- services <-- Directory
|   |   +-- models <-- Directory
|   +-- system.config.js
|   +-- index.html
+-- tsconfig.json
+-- typings.json

This is my system.config.js: js

(function (global) {
    // map tells the System loader where to look for things
    var map            = {
        'app'      : 'app', // 'dist',
        '@angular' : 'node_modules/@angular',
        'rxjs'     : 'node_modules/rxjs',
        '@models'  : 'app/models',
        '@services': 'app/services',
        '@model_services': 'app/services/model_services',
        'moment'   : 'node_modules/moment/moment.js',
        'ng2-bootstrap': 'node_modules/ng2-bootstrap'
    };
    // packages tells the System loader how to load when no filename and/or no extension
    var packages       = {
        'app' : {main: 'main', defaultExtension: 'js'},
        'rxjs': {defaultExtension: 'js'},
        '@models': {main: 'index'},
        '@services': {main: 'index'},
        '@model_services': {main: 'index'}
    };
    var ngPackageNames = [
        'common',
        'compiler',
        'core',
        'http',
        'platform-browser',
        'platform-browser-dynamic',
        'router'
    ];
    // Individual files (~300 requests):
    function packIndex(pkgName) {
        packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
    }
    // Bundled (~40 requests):
    function packUmd(pkgName) {
        packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
    }
    // Most environments should use UMD; some (Karma) need the individual index files
    var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
    // Add package entries for angular packages
    ngPackageNames.forEach(setPackageConfig);
    var config = {
        defaultJSExtensions: true,
        map: map,
        packages: packages
    };
    System.config(config);
})(this);

I ended up fixing it. I think it was actually a problem with gulp, as the dist folder was pretty messed up.

I ended up re-cloning the project and everything is ok now.

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