无法加载资源:服务器响应状态为404 - 在Angular2从rc4迁移到最新版本之后

时间:2017-03-03 12:15:13

标签: angular migration systemjs

迁移到最新的Angular版本时遇到了很大问题。

更新package.json后:

{
  "name": "test",
  "version": "0.4.5",
  "description": "ad",
  "engines": {
    "node": ">=0.12"
  },
  "private": true,
  "scripts": {
    "start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "typings": "typings",
    "postinstall": "bower install && typings install"
  },
  "license": "ISC",
  "repository": {
    "type": "git",
    "url": ""
  },
  "dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/upgrade": "2.0.0-rc.5",
    "angular-in-memory-web-api": "0.2.4",
    "angular2localization": "1.4.2",
    "core-js": "^2.4.0",
    "file-saver": "^1.3.2",
    "gulp-rename": "^1.2.2",
    "ng2-pagination": "1.0.1",
    "reflect-metadata": "^0.1.2",
    "rxjs": "5.0.1",
    "systemjs": "0.19.27",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@types/file-saver": "0.0.0",
    "concurrently": "^2.0.0",
    "del": "^2.2.2",
    "gulp": "^3.9.1",
    "gulp-autoprefixer": "^3.1.1",
    "gulp-babel": "^6.1.2",
    "gulp-cache": "^0.4.5",
    "gulp-concat": "^2.6.1",
    "gulp-cssnano": "^2.1.2",
    "gulp-eslint": "^3.0.1",
    "gulp-if": "^2.0.2",
    "gulp-imagemin": "^3.1.1",
    "gulp-include": "^2.3.1",
    "gulp-minify-css": "^1.2.4",
    "gulp-newer": "^1.3.0",
    "gulp-rev": "^7.1.2",
    "gulp-sass": "^3.0.0",
    "gulp-size": "^2.1.0",
    "gulp-sourcemaps": "^1.9.1",
    "gulp-uglify": "^2.0.0",
    "lite-server": "^2.2.0",
    "run-sequence": "^1.2.2",
    "typescript": "^2.0.3",
    "typings": "^1.0.4"
  }
}

这是我的systemjs文件:

(function (global) {
    var map = {
        'app': 'app', // 'dist',
        '@angular': 'node_modules/@angular',
        'angular-in-memory-web-api': 'node_modules/angular-in-memory-web-api',
        'rxjs': 'node_modules/rxjs',
        'ng2-pagination': 'node_modules/ng2-pagination/dist',
        'file-saver': 'node_modules/file-saver',

    };

    var packages = {
        'app': {main: 'main.js', defaultExtension: 'js'},
        'rxjs': {defaultExtension: 'js'},
        'angular-in-memory-web-api': {main: 'index.js', defaultExtension: 'js'},
        'ng2-pagination': {main: 'ng2-pagination.js', defaultExtension: 'js'},
        'file-saver': {main: 'FileSaver.js', defaultExtension: 'js'}
    };

    var ngPackageNames = [
        'common',
        'compiler',
        'core',
        'forms',
        'http',
        'platform-browser',
        'platform-browser-dynamic',
        'router',
        'upgrade',
    ];

    function packIndex (pkgName) {
        packages['@angular/' + pkgName] = {main: 'index.js', defaultExtension: 'js'};
    }

    function packUmd (pkgName) {
        packages['@angular/' + pkgName] = {main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js'};
    }

    var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;

    ngPackageNames.forEach(setPackageConfig);
    var config = {
        map: map,
        packages: packages
    };
    System.config(config);
})(this);

我收到这些错误:

app.min.js:3 GET http://localhost:3000/node_modules/@angular/common/src/facade/exceptions.js 404 (Not Found)
(index):33 Error: Error: XHR error (404 Not Found) loading http://localhost:3000/node_modules/@angular/common/src/facade/exceptions.js
    Error loading http://localhost:3000/node_modules/@angular/common/src/facade/exceptions.js as "@angular/common/src/facade/exceptions" from http://localhost:3000/angular2localization/src/services/locale-number
app.min.js:3 GET http://localhost:3000/node_modules/@angular/common/src/facade/intl.js 404 (Not Found)
app.min.js:3 GET http://localhost:3000/node_modules/@angular/common/src/pipes/invalid_pipe_argument_exception.js 404 (Not Found)
app.min.js:3 GET http://localhost:3000/traceur 404 (Not Found)
app.min.js:3 GET http://localhost:3000/node_modules/@angular/common/src/facade/exceptions.js 404 (Not Found)
app.min.js:3 GET http://localhost:3000/node_modules/@angular/common/src/facade/intl.js 404 (Not Found)
app.min.js:3 GET http://localhost:3000/node_modules/@angular/common/src/pipes/invalid_pipe_argument_exception.js 404 (Not Found)

我不知道如何解决这个问题并开始我的应用。

0 个答案:

没有答案