ReferenceError:在角度通用应用程序中未定义IDBIndex

时间:2019-05-11 16:52:21

标签: angular firebase

我正在使用“ ng serve”运行应用程序,但运行正常。 但是,当我使用“ npm run build:ssr”构建应用程序后,该应用程序已成功构建。

构建并运行angular 7通用应用程序后,我在dist文件夹中收到这些错误。

/home/trd/TRD/dpm_home_page/dist/server.js:255862

proxyRequestMethods(索引,'_ index',IDBIndex,[                                      ^ ReferenceError:未定义IDBIndex 在对象。 (/home/trd/TRD/dpm_home_page/dist/server.js:255862:38)(/home/trd/TRD/dpm_home_page/dist/server.js:26:30) 在Object.firebase(

这是我的package.json文件:

 {
  "name": "angular-io-example",
  "version": "1.0.0",
  "private": true,
  "description": "Example project from an angular.io guide.",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "lint": "tslint ./src/**/*.ts -t verbose",
    "e2e": "ng e2e",
    "build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
    "serve_dev:ssr": "node dist/server.js",
    "serve:ssr": "forever start dist/server.js",
    "build:client-and-server-bundles": "ng build --prod && ng run angular.io-example:server",
    "webpack:server": "webpack --config webpack.server.config.js --progress --colors"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/animations": "^6.1.10",
    "@angular/cdk": "^6.4.7",
    "@angular/common": "^6.1.10",
    "@angular/compiler": "^6.1.10",
    "@angular/core": "^6.1.10",
    "@angular/flex-layout": "^6.0.0-beta.18",
    "@angular/forms": "^6.1.10",
    "@angular/http": "6.0.0",
    "@angular/material": "^6.4.7",
    "@angular/platform-browser": "^6.1.10",
    "@angular/platform-browser-dynamic": "^6.1.10",
    "@angular/pwa": "^0.6.8",
    "@angular/router": "^6.1.10",
    "@angular/service-worker": "^6.1.10",
    "@angular/upgrade": "^6.1.10",
    "@firebase/app-types": "^0.3.2",
    "@firebase/auth-types": "^0.3.4",
    "@firebase/database-types": "^0.3.2",
    "@firebase/firestore-types": "^0.7.0",
    "@firebase/messaging-types": "^0.2.3",
    "@firebase/storage-types": "^0.2.3",
    "@nguniversal/express-engine": "^6.1.0",
    "@nguniversal/module-map-ngfactory-loader": "^6.1.0",
    "angular-in-memory-web-api": "^0.6.1",
    "angularfire2": "^5.1.0",
    "cdk": "^0.31.0",
    "core-js": "^2.6.5",
    "firebase": "6.0.2",
    "forever": "^1.0.0",
    "jasmine-reporters": "^2.3.2",
    "ng2-pdf-viewer": "^5.2.4",
    "protractor-html-reporter-2": "^1.0.4",
    "rxjs": "^6.5.2",
    "zone.js": "^0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.6.0",
    "@angular/cli": "^6.2.9",
    "@angular/compiler-cli": "^7.2.15",
    "@angular/platform-server": "^6.1.10",
    "@types/jasmine": "^2.8.16",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "^6.14.6",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~1.4.2",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-phantomjs-launcher": "^1.0.2",
    "lodash": "^4.17.11",
    "phantomjs-prebuilt": "^2.1.7",
    "protractor": "~5.3.0",
    "ts-loader": "^4.5.0",
    "ts-node": "^5.0.1",
    "tslint": "^5.16.0",
    "typescript": "^3.2.4",
    "webpack-cli": "^2.0.14"
  },
  "repository": {}
}

2 个答案:

答案 0 :(得分:1)

我使用setwd("~/Desktop/test") a<-system('find . | grep -i ".gz$" |wc -l') while (a<5) { system('wget -nc -tries=1 -i list.txt') } 而不是"@angular/fire": "^5.2.0-beta.3",我遇到了同样的问题,在实现“ AngularFirePerformanceModule”之后,我将其删除了; "angularfire2": "^5.1.0",问题消失了。

答案 1 :(得分:0)

如果您仍然想在app.module.ts中使用angulare / fire / performance模块,则可以这样做。

import { isPlatformBrowser } from '@angular/common';
import { AppComponent } from './app.component';

const importModuleArray: any[] = [ // your modules here ]

if (isPlatformBrowser) {
  require('@angular/fire/performance').then(module => {
    importModuleArray.push(module.AngularFirePerformanceModule);
  });}

@NgModule({
  **your declarated modules as AppComponent for example**
  ],
  imports: importModuleArray
  bootstrap: [AppComponent]
})