代码之家  ›  专栏  ›  技术社区  ›  Lucas Freitas

Angular6-Prod Build无法访问

  •  0
  • Lucas Freitas  · 技术社区  · 6 年前

    我正在将我的Angular6应用程序转换为PWA,并面临一些问题。

    当我用ng-serve运行应用程序时,一切都正常。

    当我发布应用程序或使用ng-serve-prod运行时,应用程序打开但无法加载登录屏幕,控制台中出现错误“referenceerror:subscription is not defined”。

    错误来自“subjectsubscription.js.pre-build optimizer.js”

    这是我的tsconfig.json

    {
      "compileOnSave": false,
      "compilerOptions": {
        "moduleResolution": "node",
        "target": "es6",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "skipDefaultLibCheck": true,
        "lib": [ "es6", "dom" ],
        "types": [ "node", "core-js" ],
        "typeRoots": [
          "../node_modules/@types"
        ]
      },
      "include": [ "../src/**/*" ],
      "exclude": [ "../bin", "../node_modules" ],
      "atom": { "rewriteTsconfig": false }
    }
    

    这是我的tsconfig.app.json(用于prod build)

    {
      "extends": "./tsconfig.json",
      "compilerOptions": {
        "outDir": "../out-tsc/app",
        "baseUrl": "./",
        "module": "es2015",
        "types": []
      },
      "exclude": [
        "test.ts",
        "**/*.spec.ts"
      ]
    }
    

    这是我的包裹.json

    "private": true,
    "dependencies": {
    "@angular/animations": "6.0.3",
    "@angular/common": "6.0.3",
    "@angular/compiler": "6.0.3",
    "@angular/core": "6.0.3",
    "@angular/forms": "6.0.3",
    "@angular/http": "6.0.3",
    "@angular/platform-browser": "6.0.3",
    "@angular/platform-browser-dynamic": "6.0.3",
    "@angular/platform-server": "6.0.3",
    "@angular/pwa": "^0.8.9",
    "@angular/router": "6.0.3",
    "@angular/service-worker": "6.0.3",
    "@aspnet/signalr": "^1.0.3",
    "@aspnet/signalr-protocol-msgpack": "^1.0.3",
    "@nguniversal/module-map-ngfactory-loader": "^6.0.0",
    "angular-2-local-storage": "^2.0.0",
    "angular-archwizard": "^3.0.0",
    "angular-confirmation-popover": "^4.1.0",
    "angular2-notifications": "^1.0.2",
    "angular2-text-mask": "^9.0.0",
    "aspnet-prerendering": "^3.0.1",
    "bootstrap": "^3.3.7",
    "chart.js": "^2.7.2",
    "core-js": "^2.4.1",
    "file-saver": "^1.3.8",
    "font-awesome": "^4.7.0",
    "jquery": "^3.3.1",
    "moment": "^2.22.2",
    "ng-sidebar": "^8.0.0",
    "ng-spin-kit": "^5.1.1",
    "ng2-charts": "^1.6.0",
    "ng2-dragula": "^1.5.0",
    "ng2-select": "^2.0.0",
    "ngx-bootstrap": "^3.1.3",
    "ngx-mydatepicker": "^2.4.5",
    "ngx-ui-switch": "^8.0.0-beta.0",
    "primeicons": "^1.0.0-beta.7",
    "primeng": "^6.0.0-beta.1",
    "quill": "^1.3.6",
    "rxjs": "^6.2.0",
    "text-mask-addons": "^3.7.2",
    "typings": "^2.1.1",
    "zone.js": "~0.8.26"
    },
    "devDependencies": {
    "@angular-devkit/build-angular": "0.12.3",
    "@angular/cli": "^6.0.7",
    "@angular/compiler-cli": "6.0.3",
    "@angular/language-service": "6.0.3",
    "@types/core-js": "^2.5.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.3.0",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^3.1.4",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.4.2",
    "ts-node": "~4.1.0",
    "tslint": "^5.10.0",
    "typescript": "2.7.2"
    },
    "optionalDependencies": {
      "node-sass": "^4.9.0"
    }
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Lucas Freitas    6 年前

    将RXJS更新到6.2.2解决了这个问题。

    "rxjs": "6.2.2",
    

    我认为问题与@angular devkit有关,它需要RXJS 6.2.2

    "@angular-devkit/architect": {
          "version": "0.8.9",
          "resolved": "https://registry.npmjs.org/@angular-devkit/architect/-/architect-0.8.9.tgz",
          "integrity": "sha512-2tiGPkvJyFY/G3a27uC8r6Jj3H5m8SxjMqhjNUQ5AtNumweTBPt3YIYMNAvHUmxG0nA9upDolVXFmoQGK9AhKQ==",
          "dev": true,
          "requires": {
            "@angular-devkit/core": "0.8.9",
            "rxjs": "6.2.2"
          },
          "dependencies": {
            "rxjs": {
              "version": "6.2.2",
              "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.2.2.tgz",
              "integrity": "sha512-0MI8+mkKAXZUF9vMrEoPnaoHkfzBPP4IGwUYRJhIRJF6/w3uByO1e91bEHn8zd43RdkTMKiooYKmwz7RH6zfOQ==",
              "dev": true,
              "requires": {
                "tslib": "^1.9.0"
              }
            }
          }
        },