Angular node_modules/graphql-tag/lib/index.d.ts(2,57) 中的 7 错误:错误 TS1005:“,”预期

Angular 7 ERROR in node_modules/graphql-tag/lib/index.d.ts(2,57): error TS1005: ',' expected

您好,我在执行 运行 ng serve 命令时遇到问题。我的 package.json 文件是

{
"name": "Myapp",
"version": "7.0.0",
"scripts": {
    "ng": "ng",
    "local-dev": "ng serve --progress --port 4200",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
},
"private": true,
"dependencies": {
    "@angular/animations": "7.1.0",
    "@angular/cdk": "7.1.0",
    "@angular/common": "7.1.0",
    "@angular/compiler": "7.1.0",
    "@angular/core": "7.1.0",
    "@angular/flex-layout": "7.0.0-beta.19",
    "@angular/forms": "7.1.0",
    "@angular/http": "7.1.0",
    "@angular/material": "7.1.0",
    "@angular/platform-browser": "7.1.0",
    "@angular/platform-browser-dynamic": "7.1.0",
    "@angular/router": "7.1.0",
    "@ngx-translate/core": "11.0.1",
    "@ngx-translate/http-loader": "4.0.0",
    "apollo-angular": "^1.5.0",
    "apollo-angular-link-http": "^1.5.0",
    "apollo-cache-inmemory": "^1.4.3",
    "apollo-client": "^2.4.13",
    "bootstrap": "^4.3.1",
    "buffer": "^5.2.1",
    "chart.js": "^2.7.3",
    "classlist.js": "^1.1.20150312",
    "core-js": "2.5.7",
    "docx": "^4.7.1",
    "docxtemplater": "^3.9.9",
    "file-saver": "^2.0.1",
    "fs": "0.0.1-security",
    "graphql": "^14.1.1",
    "graphql-code-generator": "^0.17.0",
    "graphql-tag": "^2.10.1",
    "hammerjs": "^2.0.8",
    "moment": "^2.24.0",
    "moment-range": "^4.0.2",
    "msal": "^0.2.4",
    "ng2-charts": "1.6.0",
    "ngx-bootstrap": "^3.3.0",
    "ngx-editor": "^4.1.0",
    "ngx-quill": "^7.3.2",
    "node-sass": "^4.13.1",
    "quill": "^1.3.7",
    "rxjs": "6.3.3",
    "web-animations-js": "^2.3.1",
    "zone.js": "0.8.26"
},
"devDependencies": {
    "@angular-devkit/build-angular": "0.10.6",
    "@angular/cli": "7.0.6",
    "@angular/compiler-cli": "7.1.0",
    "@angular/language-service": "7.1.0",
    "@types/jasmine": "3.3.0",
    "@types/jasminewd2": "2.0.6",
    "@types/node": "10.12.10",
    "codelyzer": "4.5.0",
    "jasmine-core": "3.3.0",
    "jasmine-spec-reporter": "4.2.1",
    "karma": "3.1.1",
    "karma-chrome-launcher": "2.2.0",
    "karma-coverage-istanbul-reporter": "2.0.4",
    "karma-jasmine": "2.0.1",
    "karma-jasmine-html-reporter": "1.4.0",
    "protractor": "5.4.1",
    "ts-node": "7.0.1",
    "tslint": "5.11.0",
    "typescript": "3.1.1"
}

}

WHile 运行 ng serve 我明白了

ERROR in node_modules/graphql-tag/lib/index.d.ts(2,57): error TS1005: ',' expected. node_modules/graphql-tag/lib/index.d.ts(2,63): error TS1005: ',' expected. i 「wdm」: Failed to compile.

下面是错误信息的截图。请帮我解决。提前致谢!!

我很确定这是一个依赖性问题。

你的 angular 项目真的过时了(看看这个页面 https://angular.io/guide/releases#support-policy-and-schedule)你应该花点时间把它升级到最新版本。我也建议提高您的依赖项版本。您正在使用 angular-apollo v1.5,它非常旧并且可能与您当前的 graphql-tag 不兼容。如果您没有硬锁定依赖项版本,则很难调试过时的环境。

使用 ng updatenpm outdatednpm update 使您的项目尽可能保持最新。也许删除你的 node_modules 和 package-lock.json 和 运行 npm install 以确保你有一个合适的开发环境。

没有 stackblitz 或 github 回购,很难为您提供更多帮助。