【问题标题】:ng serve errors on node modules with apollo clientng 在使用 apollo 客户端的节点模块上服务错误
【发布时间】:2021-12-30 01:41:56
【问题描述】:

您好,我们已将 Angular 6 升级到 7.2 并安装了 graphql。在尝试运行 ng serve 时,我们在节点模块的 apollo 客户端中遇到了多个错误。

node_modules/@apollo/client/core/types.d.ts(38,1) 中的错误:错误 TS1128:需要声明或声明。 node_modules/@apollo/client/core/types.d.ts(38,13): 错误 TS1005: ';'预期的。 node_modules/@apollo/client/utilities/observables/Observable.d.ts(3,1):错误 TS1128:需要声明或声明。 node_modules/@apollo/client/utilities/observables/Observable.d.ts(3,13): error TS1005: ';'预期的。 node_modules/@apollo/client/utilities/observables/Observable.d.ts(3,61):错误 TS1109:预期表达式。 node_modules/graphql-tag/lib/index.d.ts(2,57): 错误 TS1005: ',' 预期。 node_modules/graphql-tag/lib/index.d.ts(2,63): 错误 TS1005: ',' 预期。 node_modules/ts-invariant/lib/invariant.d.ts(6,87): 错误 TS1144: '{' or ';'预期的。 node_modules/ts-invariant/lib/invariant.d.ts(7,49): 错误 TS1005: ']' 预期。 node_modules/ts-invariant/lib/invariant.d.ts(7,51):错误 TS1134:需要变量声明。 node_modules/ts-invariant/lib/invariant.d.ts(7,83): 错误 TS1005: ';'预计。

我们的包 json 看起来像 -->

{

  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "graphql-codegen": "npx graphql-codegen"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^7.2.11",
    "@angular/common": "^7.2.11",
    "@angular/compiler": "^7.2.11",
    "@angular/core": "^7.2.11",
    "@angular/forms": "^7.2.11",
    "@angular/http": "^7.2.11",
    "@angular/platform-browser": "^7.2.11",
    "@angular/platform-browser-dynamic": "^7.2.11",
    "@angular/router": "^7.2.11",
    "@apollo/client": "^3.0.0",
    "@contentful/rich-text-html-renderer": "^14.1.1",
    "@ng-bootstrap/ng-bootstrap": "^4.1.0",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@types/angular": "^1.8.3",
    "angular-2-dropdown-multiselect": "^1.9.0",
    "angular-image-slider": "0.0.8",
    "angular-notifier": "^4.1.1",
    "apollo-angular": "^2.6.0",
    "bootstrap": "^4.6.1",
    "contentful": "^7.15.2",
    "core-js": "^2.6.12",
    "font-awesome": "^4.7.0",
    "graphql": "^15.0.0",
    "jquery": "^3.6.0",
    "lodash": "^4.17.21",
    "marked": "^0.6.3",
    "moment": "^2.29.1",
    "ng-simple-slideshow": "^1.2.9",
    "ngx-cookie-service": "^1.0.10",
    "ngx-device-detector": "^1.5.2",
    "ngx-markdown": "^8.2.2",
    "ngx-slick-carousel": "^0.4.7",
    "ngx-text-overflow-clamp": "0.0.1",
    "ngx-toastr": "^10.2.0",
    "rxjs": "6.3.0",
    "slick-carousel": "^1.8.1",
    "underscore": "^1.13.1",
    "zone.js": "^0.8.16"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.10.7",
    "@angular/cli": "^7.1.0",
    "@angular/compiler-cli": "^7.1.0",
    "@angular/language-service": "^7.1.0",
    "@graphql-codegen/cli": "^2.3.0",
    "@graphql-codegen/typescript": "^2.4.1",
    "@graphql-codegen/typescript-apollo-angular": "^3.3.1",
    "@graphql-codegen/typescript-operations": "^2.2.1",
    "@types/chart.js": "^2.9.34",
    "@types/jasmine": "^3.10.2",
    "@types/jasminewd2": "^2.0.10",
    "@types/node": "^16.11.7",
    "codelyzer": "^6.0.2",
    "jasmine-core": "^3.10.1",
    "jasmine-spec-reporter": "^7.0.0",
    "karma": "^6.3.9",
    "karma-chrome-launcher": "^3.1.0",
    "karma-cli": "^2.0.0",
    "karma-coverage-istanbul-reporter": "^2.1.1",
    "karma-jasmine": "^4.0.1",
    "karma-jasmine-html-reporter": "^1.7.0",
    "protractor": "^7.0.0",
    "rxjs-tslint": "^0.1.8",
    "ts-node": "^5.0.1",
    "tslint": "^5.7.0",
    "typescript": "~3.2.2",
    "webpack": "^4.46.0"
  }
}

请任何人帮助解决如何在运行我们的应用程序时消除这些错误。

【问题讨论】:

    标签: typescript graphql angular7 apollo-client


    【解决方案1】:

    升级打字稿可以解决你的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-01
      • 1970-01-01
      • 2021-12-06
      相关资源
      最近更新 更多