首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从角5升级到角8,SystemJS问题

从角5升级到角8,SystemJS问题
EN

Stack Overflow用户
提问于 2019-08-05 23:25:48
回答 2查看 1.5K关注 0票数 2

我有一个ASP.Net MVC制作的应用程序,里面有角5来显示视图。我将角从5更新到8,现在我很难让它工作,因为这个错误:

误差图像

似乎是关于SystemJS或Zone.js的

如果有些文件没有正确加载,我还在dev工具中观察过,但是一切似乎都很好。

我不知道这里的问题是什么,所以我不能自己解决,谢谢你的帮助。

我的package.json:

代码语言:javascript
复制
{
  "name": "App",
  "version": "1.0.0",
  "private": true,
  "description": "App package.json",
  "scripts": {
    "ng": "ng",
    "build": "ng build --prod",
    "start": "ng serve",
    "test": "ng test",
    "i18n": "ng-xi18n",
    "lint": "tslint ./src/**/*.ts -t verbose"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/common": "^8.2.0",
    "@angular/compiler": "^8.2.0",
    "@angular/core": "^8.2.0",
    "@angular/forms": "^8.2.0",
    "@angular/platform-browser": "^8.2.0",
    "@angular/platform-browser-dynamic": "^8.2.0",
    "@angular/platform-server": "^8.2.0",
    "@angular/router": "^8.2.0",
    "@angular/upgrade": "^8.2.0",
    "@ng-bootstrap/ng-bootstrap": "^5.1.0",
    "core-js": "^3.1.4",
    "dexie": "~2.0.4",
    "file-saver": "^2.0.2",
    "minimatch": "~3.0.4",
    "ngx-toastr": "^10.0.4",
    "performance-now": "^2.1.0",
    "rxjs": "^6.5.2",
    "rxjs-compat": "^6.5.2",
    "systemjs": "^0.21.5",
    "text-encoding": "^0.7.0",
    "zone.js": "^0.9.1"
  },
  "devDependencies": {
    "@angular/animations": "^8.2.0",
    "@angular/cli": "^8.2.0",
    "@angular/compiler-cli": "^8.2.0",
    "@types/file-saver": "^2.0.1",
    "@types/google.analytics": "^0.0.40",
    "@types/jasmine": "^3.3.16",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "^12.6.9",
    "jasmine-core": "^3.4.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^4.2.0",
    "karma-chrome-launcher": "^3.0.0",
    "karma-cli": "^2.0.0",
    "karma-coverage-istanbul-reporter": "^2.1.0",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "karma-phantomjs-launcher": "^1.0.4",
    "lodash": "^4.17.15",
    "phantomjs-prebuilt": "^2.1.16",
    "protractor": "^5.4.2",
    "ts-node": "^8.3.0",
    "tslint": "^5.18.0",
    "typescript": "^3.5.3"
  },
  "repository": {},
  "main": "karma-test-shim.js"
}

我的systemjs.config.js:

代码语言:javascript
复制
/**
 * System configuration for Angular.
 */
(function (global) {
    System.config({
        paths: {
            // paths serve as alias
            'npm:': 'Js/angular/node_modules/'
        },
        // map tells the System loader where to look for things
        map: {
            // our app is within the app folder
            app: 'Js/angular/src/app',

            src: 'Js/angular/src',

            // angular bundles
            '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
            '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
            '@angular/common/http': 'npm:@angular/common/bundles/common-http.umd.js',
            '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
            '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
            '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
            '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
            '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

            // other libraries                        
            '@ng-bootstrap/ng-bootstrap': 'npm:@ng-bootstrap/ng-bootstrap/bundles/ng-bootstrap.umd.js',
            'rxjs': 'npm:rxjs',
            'tslib': 'npm:tslib/tslib.js',
            'dexie': 'npm:dexie/dist/dexie.js',
            'file-saver': 'npm:file-saver/dist/FileSaver.min.js',
            'text-encoding': 'npm:text-encoding/lib/encoding.js'
        },
        // packages tells the System loader how to load when no filename and/or no extension
        packages: {
            src: {
                main: 'Js/angular/src/main.js',
                defaultExtension: 'js'
            },
            rxjs: {
                main: 'index.js',
                defaultExtension: 'js'
            },
            'rxjs/operators': {
                main: 'index.js',
                defaultExtension: 'js'
            },
            'dexie': {
                format: 'amd'
            },
            'file-saver': {
                format: 'global'
            }
        }
    });
})(this);

关于角的束(App_Start/BundleConfig.cs):

代码语言:javascript
复制
bundles.Add(new ScriptBundle("~/bundles/angular").Include(
                        "~/Js/angular/node_modules/core-js/client/shim.min.js",
                        "~/Js/angular/node_modules/zone.js/dist/zone.js",
                        "~/Js/angular/node_modules/systemjs/dist/system.src.js",
                        "~/Js/angular/src/systemjs.config.js"));
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-08-06 11:56:38

在更新过程中,我从Core-js2.5.3转到3.1.4,包内部目录被更改。因此,"~/Js/angular/node_modules/core-js/client/shim.min.js"BundleConfig.cs中没有正确加载。

我将Core回滚到2.6.9,它具有相同的目录结构。

我也可以留在v3.1.4中并更正引用。

票数 0
EN

Stack Overflow用户

发布于 2019-08-06 03:38:12

请尝试添加应用程序的主条目。在处理这类问题时,这对我来说是可行的:

代码语言:javascript
复制
packages: {
  app: {
    main: 'main.js',
    defaultExtension: 'js',
  },
  rxjs: {
    defaultExtension: 'js'
  }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57367138

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档