2016-07-04 8 views
1

Ich erhalte die folgende Ausnahme, wenn die Anwendung auf den Browser geladen wird. Bitte finden Sie die Konfigurationsdateien und Fehlerdetails unten.Fehler beim Laden in angular2 erhalten RC4: Fehler: XHR-Fehler (404 Not Found) Laden

Fehler

Failed to load resource: the server responded with a status of 404 (Not Found) 
    http://localhost:59856/node_modules/@angular/core/index.js Failed to load resource: the server responded with a status of 404 (Not Found) 
    localhost/:17 Error: Error: XHR error (404 Not Found) loading http://localhost:59856/node_modules/@angular/core/index.js 
      at XMLHttpRequest.wrapFn [as _onreadystatechange] (https://npmcdn.com/[email protected]?main=browser:769:30) 
      at ZoneDelegate.invokeTask (https://npmcdn.com/[email protected]?main=browser:356:38) 
      at Zone.runTask (https://npmcdn.com/[email protected]?main=browser:256:48) 
      at XMLHttpRequest.ZoneTask.invoke (https://npmcdn.com/[email protected]?main=browser:423:34) 
     Error loading http://localhost:59856/node_modules/@angular/core/index.js as "@angular/core" from http://localhost:59856/app/main.js(anonymous function) @ localhost/:17 
    http://localhost:59856/node_modules/@angular/platform-browser-dynamic/index.js Failed to load resource: the server responded with a status of 404 (Not Found) 
    http://localhost:59856/styles.css Failed to load resource: the server responded with a status of 404 (Not Found) 

Package.json

 { 
     "version": "1.0.0", 
     "name": "ngcorecontacts", 
     "scripts": { 
     "postinstall": "typings install", 
     "typings": "typings" 
     }, 
     "dependencies": { 
    "@angular/common": "2.0.0-rc.4", 
    "@angular/compiler": "2.0.0-rc.4", 
    "@angular/core": "2.0.0-rc.4", 
    "@angular/forms": "0.2.0", 
    "@angular/http": "2.0.0-rc.4", 
    "@angular/platform-browser": "2.0.0-rc.4", 
    "@angular/platform-browser-dynamic": "2.0.0-rc.4", 
    "@angular/router": "3.0.0-beta.2", 

    "systemjs": "0.19.27", 
    "core-js": "^2.4.0", 
    "reflect-metadata": "^0.1.3", 
    "rxjs": "5.0.0-beta.6", 
    "zone.js": "^0.6.12", 

    "bootstrap": "^3.3.6" 
    }, 
    "devDependencies": { 
     "concurrently": "^2.0.0", 
     "lite-server": "^2.2.0", 
     "tslint": "^3.7.4", 
     "typescript": "^1.8.10", 
     "typings": "^1.0.4" 
    }, 
    "repository": {} 

In Systemjs.Config.js

/** 
* System configuration for Angular 2 samples 
* Adjust as necessary for your application needs. 
*/ 
(function (global) { 

    // map tells the System loader where to look for things 
    var map = { 
     'app': 'app', 
     'rxjs': 'node_modules/rxjs', 
     '@angular': 'node_modules/@angular' 
    }; 

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

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

    // 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 
    }; 

    System.config(config); 

})(this); 

tsconfig.json

{ 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": true, 
    "suppressImplicitAnyIndexErrors": true 
    } 
} 

Was fehlt mir hier?

+0

hochgeladen Welche Version versuchen Sie - RC1 oder RC4? Sie package.json zeigt auf 2.0.0-rc.1 – Sanket

+0

Die config-Einträge aktualisiert, immer noch das gleiche Problem, irgendwelche Ideen? – Krishnan

Antwort

1

Ich fand die Antwort.

Sie können die node_modules nicht aus wwwroot importieren, aber Sie müssen die Bundles in einem Zielordner in wwwroot kopieren, zum Beispiel nach gulp, und dann von dort von systemjs.config.js importieren Die funktionierende Lösung von AspNet Kern mit Angular2-RC4, habe ich als Zip-Datei in github

3

ist dies, weil Sie Ihre Anwendung von appScripts geladen werden, wie an dieser Stelle darauf:

"outDir": "../wwwroot/appScripts/", aber Ihre sind an app in Ihrem System Config bezieht.

schnelle Lösung wäre, die outDir von tsconfig.json zu entfernen und die Anwendung auszuführen. Idealerweise sollten Sie @ angular-cli für den Build verwenden. schauen here

+0

Aktualisiert die Config-Einträge, immer noch mit dem gleichen Problem, irgendwelche Ideen? – Krishnan

+0

Können Sie einen Plünderer bereitstellen, der das Problem veranschaulicht? – DeborahK

+0

In Plunker funktioniert es gut, gleiche Konfigurationseinstellungen und andere Komponenten, wenn in Visual Studio IDE (AspNet Core RC2) platziert, beim Ausführen der Anwendung bekomme ich diesen Fehler. Bitte laden Sie die Zip-Datei von der Github-URL, WebApplication1.zip-Datei von github.com/snkrishnan1/Angular2RC4 herunter. In diesem Github-Repo habe ich die gleiche Konfiguration aus den Quickstart-Tutorials verwendet, aber die oben genannten Fehler erhalten. Haben Sie eine funktionierende Lösung auf AspNet Core RC2 mit Angular2 RC4? – Krishnan

Verwandte Themen