在角度10中安装缺少的依赖项

时间:2020-07-29 09:49:35

标签: angular apollo apollo-client apollo-angular

我在我的angular 10中使用了阿波罗,并且在运行background-size

后遇到了这个问题

目标入口点“阿波罗角”中的错误已丢失 依赖项:

  • @ angular / core
  • 阿波罗客户
  • rxjs
  • rxjs / operators
  • 阿波罗链接

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

4 个答案:

答案 0 :(得分:4)

我对'@ 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解决了该问题。该文档说它支持Angular10。此版本中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",

答案 1 :(得分: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

答案 2 :(得分:2)

来自apollo-angular#installation文档:

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

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

我正在使用角度v11.0.3。将apollo-angular降级为v1.10.0之后。编译成功。

删除apollo-angular v2。

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"
  },

答案 3 :(得分:0)

签出此内容:https://apollo-angular.com/docs/get-started

npm install apollo-angular @apollo/client graphql