首页 > 解决方案 > 离子服务因打字稿错误而失败

问题描述

我有一个基本的 Ionic 应用程序,我正在使用 Firebase 和 Firestore 作为 Auth 和 DB 开发。我在我的 Windows 和 MacOS 机器上遇到了同样的问题,而我的朋友在他的 MacOS 机器上也遇到了同样的问题。此外,问题是通过我们自己的代码库以及当我们克隆具有类似设置(Ionic + Firebase)的 git 存储库时出现的。

在 environment.ts 文件中添加 Firebase 信息并添加 firebase 包后,我们运行 Ionic Serve 并始终得到相同的 TS1005 错误。

我们已将 Typescript 回滚到 3.4.3。我们最初有 3.6.4,但发现对需要低于 3.5.0 版本的依赖项的引用。

我们已将 Node 更新到版本 12,并尝试了 NPM 安装和更新,以确保我们拥有正确的软件包。

下面是我们的 Packages.json:

{
  "name": "appname",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~8.1.2",
    "@angular/compiler": "~8.1.2",
    "@angular/core": "~8.1.2",
    "@angular/fire": "^5.2.1",
    "@angular/forms": "~8.1.2",
    "@angular/platform-browser": "~8.1.2",
    "@angular/platform-browser-dynamic": "~8.1.2",
    "@angular/router": "~8.1.2",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^4.7.1",
    "core-js": "^2.5.4",
    "firebase": "^7.2.2",
    "rxjs": "~6.5.1",
    "tslib": "^1.9.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/architect": "~0.801.2",
    "@angular-devkit/build-angular": "~0.801.2",
    "@angular-devkit/core": "~8.1.2",
    "@angular-devkit/schematics": "~8.1.2",
    "@angular/cli": "8.1.3",
    "@angular/compiler": "~8.1.2",
    "@angular/compiler-cli": "~8.1.2",
    "@angular/language-service": "~8.1.2",
    "@ionic/angular-toolkit": "~2.0.0",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.0.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.4.3"
  },
  "description": "An Ionic project"
}

我们希望 Ionic Serve 命令在浏览器中加载应用程序。我们在终端中收到以下错误:

[ng] ERROR in src/environments/environment.prod.ts:3:3 - error TS1005: ',' expected.
[ng] 3   firebaseConfig: {
[ng]     ~~~~~~~~~~~~~~
[ng] src/environments/environment.prod.ts:12:4 - error TS1005: ',' expected.
[ng] 12   };
[ng]       ~
[ng] src/environments/environment.ts:7:3 - error TS1005: ',' expected.
[ng] 7   firebaseConfig: {
[ng]     ~~~~~~~~~~~~~~
[ng] src/environments/environment.ts:16:4 - error TS1005: ',' expected.
[ng] 16   };
[ng]       ~
[ng]

标签: angulartypescriptionic-framework

解决方案


推荐阅读