0

嗨,我在运行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"
}

}

在运行 ng serve 时,我得到了这个

node_modules/graphql-tag/lib/index.d.ts(2,57) 中的错误:错误 TS1005:“,”预期。node_modules/graphql-tag/lib/index.d.ts(2,63): 错误 TS1005: ',' 预期。i ∩╜ówdm∩╜ú:编译失败。

以下是错误消息的屏幕截图。请帮我解决。先感谢您!!

在此处输入图像描述

4

1 回答 1

0

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

您的 Angular 项目确实已经过时(请查看此页面https://angular.io/guide/releases#support-policy-and-schedule),您可能应该花时间将其升级到最新版本。我也建议增加你的依赖版本。您使用的是非常旧的 angular-apollo v1.5,可能与您当前的 graphql-tag 不兼容。如果您没有硬锁定依赖项版本,则很难调试过时的环境。

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

如果没有 stackblitz 或 github 存储库,将很难为您提供更多帮助。

于 2021-06-08T15:51:43.650 回答