0

我正在将应用程序从 angular 2 升级到 angular 6。升级 rxjs 也在途中,并安装了 rxjs-compact。尝试运行应用程序时出现此错误。错误、systemjs.config.js、tsconfig.json 和 package.json 包含在此处。

错误:

       (index):27 Error: (SystemJS) exports is not defined
       ReferenceError: exports is not defined
       at eval [this is not a link] 
       (http://localhost:3000/dist/app/rxjsextensions.js:2:23)
       at eval (<anonymous>)
       at Object.eval [this is not a link] 
       (http://localhost:3000/dist/app/app.module.js:12:1)
       at eval (http://localhost:3000/dist/app/app.module.js:323:4)
       Evaluating http://localhost:3000/dist/app/rxjs-extensions.js
       Evaluating http://localhost:3000/dist/app/app.module.js
       Evaluating http://localhost:3000/dist/app/main.js
       Error loading http://localhost:3000/dist/app/main.js
       at eval (http://localhost:3000/dist/app/rxjs-extensions.js:2:23)
       at eval (<anonymous>)
       at Object.eval (http://localhost:3000/dist/app/app.module.js:12:1)
       at eval (http://localhost:3000/dist/app/app.module.js:323:4)
       Evaluating http://localhost:3000/dist/app/rxjs-extensions.js
       Evaluating http://localhost:3000/dist/app/app.module.js
       Evaluating http://localhost:3000/dist/app/main.js
       Error loading http://localhost:3000/dist/app/main.js

systemjs.config.js:

 (function(global) {
        System.config({
          paths: {
        // paths serve as alias
          'npm:': 'node_modules/'
        },
       // map tells the System loader where to look for things
         map: {
        // our app is within the app folder
         app: 'dist/app',

        // angular bundles
        '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
        '@angular/common': 'npm:@angular/common/bundles/common.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/http': 'npm:@angular/http/bundles/http.umd.js',
        '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
        '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

        // other libraries
        'rxjs': 'npm:rxjs',
        'ng2-charts': 'npm:ng2-charts/bundles/ng2-charts.umd.js',
        'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
        //'ng2-select2': 'npm:ng2-select2'
      },
      // packages tells the System loader how to load when no filename and/or no extension
        packages: {
        'app': {
            main: './main.js',
            defaultExtension: 'js'
        },

      'rxjs/ajax': {main: 'index.js', defaultExtension: 'js' },
      'rxjs/operators': {main: 'index.js', defaultExtension: 'js' },
      'rxjs/testing': {main: 'index.js', defaultExtension: 'js' },
      'rxjs/websocket': {main: 'index.js', defaultExtension: 'js' },
      'rxjs': { main: 'index.js', defaultExtension: 'js' }
      }});
      })(this);

tsconfig.js:

{
  "compilerOptions": {
    "outDir": "dist/app",
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": false,
    "suppressImplicitAnyIndexErrors": true
  }
}

包.json:

{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "description": "QuickStart package.json from the documentation, supplemented with testing support",
  "scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
    "e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
    "lint": "tslint ./app/**/*.ts -t verbose",
    "lite": "lite-server",
    "pree2e": "webdriver-manager update",
    "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
    "test-once": "tsc && karma start karma.conf.js --single-run",
    "tsc": "tsc",
    "tsc:w": "tsc -w"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/common": "~6.0.0",
    "@angular/compiler": "~6.0.0",
    "@angular/core": "~6.0.0",
    "@angular/forms": "~6.0.0",
    "@angular/http": "~6.0.0",
    "@angular/platform-browser": "~6.0.0",
    "@angular/platform-browser-dynamic": "~6.0.0",
    "@angular/router": "~6.0.0",
    "chart.js": "^2.6.0",
    "core-js": "^2.4.1",
    "ng2-charts": "^1.6.0",
    "reflect-metadata": "^0.1.8",
    "rxjs": "6.1.0",
    "rxjs-compat": "^6.3.2",
    "systemjs": "0.19.40",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "concurrently": "^3.1.0",
    "lite-server": "^2.2.2",
    "typescript": "2.8.3",
    "canonical-path": "0.0.2",
    "http-server": "^0.9.0",
    "tslint": "^3.15.1",
    "lodash": "^4.16.4",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "4.0.9",
    "webdriver-manager": "10.2.5",
    "rimraf": "^2.5.4",
    "@types/node": "10.0.4",
    "@types/selenium-webdriver": "^2.53.33"
  },
  "repository": {}
}
4

0 回答 0