4

我在我的 angular 10 中使用 apollo,运行后我遇到了这个问题ng serve

目标入口点“apollo-angular”中的错误缺少依赖项:

  • @角/核心
  • 阿波罗客户端
  • rxjs
  • rxjs/运营商
  • 阿波罗链接

是否有命令在我的项目中安装所有这些缺少的依赖项......即使我认为我已经安装了所有这些......奇怪的是我有这些错误。有人可以在我身上闪耀一些智慧吗,提前谢谢你

4

4 回答 4

6

我对“@apollo/client/core”有同样的问题

ERROR in The target entry-point "apollo-angular" has missing dependencies:

@apollo/client/core

从 apollo.d.ts 中的“@apollo/client/core”导入无法正常工作。将 apollo-angular 降级到 1.10.0 解决了这个问题。文档说它支持 Angular 10。此版本中 apollo.d.ts 中的导入如下所示:

import { ApolloClient, QueryOptions, MutationOptions, ApolloQueryResult, SubscriptionOptions, ApolloClientOptions } from 'apollo-client';

这就是我的 package.json 中的依赖项的样子:

"apollo-angular": "^1.10.0",
"apollo-angular-link-http": "^1.11.0",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link": "^1.2.14",
"graphql": "^15.1.0",
"graphql-tag": "^2.10.4",
于 2020-09-09T09:58:59.107 回答
3

来自apollo-angular#installation文档:

如果您使用的是 Apollo-Client v3,请确保使用 apollo-angular@v2

如果您使用的是 Apollo-Client v2,请确保使用 apollo-angular@v1(对于 Angular 10 支持,请确保使用 v1.10.0)

我正在使用 angular v11.0.3。降级apollo-angularv1.10.0. 编译成功。

删除apollo-angularv2。

npm rm apollo-angular -S

安装apollo-angular@1.10.0

npm i apollo-angular@1.10.0 -S

package.json

 "dependencies": {
    "@angular/animations": "~11.0.3",
    "@angular/common": "~11.0.3",
    "@angular/compiler": "~11.0.3",
    "@angular/core": "~11.0.3",
    "@angular/forms": "~11.0.3",
    "@angular/platform-browser": "~11.0.3",
    "@angular/platform-browser-dynamic": "~11.0.3",
    "@angular/router": "~11.0.3",
    "apollo-angular": "^1.10.0",
    "apollo-angular-link-http": "^1.11.0",
    "apollo-cache-inmemory": "^1.6.6",
    "apollo-client": "^2.6.10",
    "apollo-link": "^1.2.14",
    "apollo-link-error": "^1.1.13",
    "detect-browser": "^5.2.0",
    "graphql": "^15.4.0",
    "graphql-codegen-add": "^0.18.2",
    "graphql-tag": "^2.11.0",
    "rxjs": "~6.6.0",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.2"
  },
于 2020-12-04T08:32:10.960 回答
2

我只是有同样的问题。Angular 10 不能很好地与 Apollo 配合使用。恢复到以前的 Angular 版本应该可以修复它。

您可以将package.json中的角度版本更改为类似

    "dependencies": {
        "@angular/animations": "~9.1.7",
        "@angular/common": "~9.1.7",
        "@angular/compiler": "~9.1.7",
        "@angular/core": "~9.1.7",
        "@angular/forms": "~9.1.7",
        "@angular/platform-browser": "~9.1.7",
        "@angular/platform-browser-dynamic": "~9.1.7",
        "@angular/router": "~9.1.7"

或者任何你喜欢的,只要它在 Angular 10 之前。

之后删除package-lock.json,删除node_module并执行

npm i
于 2020-08-07T03:17:33.070 回答
1

结帐:https ://apollo-angular.com/docs/get-started

npm install apollo-angular @apollo/client graphql
于 2020-12-05T14:55:05.937 回答