4

I am using apollo in my angular 10 and I have this problem after running ng serve

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

  • @angular/core
  • apollo-client
  • rxjs
  • rxjs/operators
  • apollo-link

Is there a command to install all this missing dependencies in my project...even though I think I have installed all these..strange that I have these errors. Can someone shine some wisdom in me,thank you in advance

Lin Du
  • 88,126
  • 95
  • 281
  • 483
PureAbap
  • 99
  • 3
  • 13
  • 1
    Look like you didnt import or declare as provider ApolloModule in your ngModule. Did you follow all the steps of the documentation? https://www.apollographql.com/docs/angular/basics/setup/ – Meadow Jul 29 '20 at 10:06
  • @Meadow I did run `ng add apollo-angular` ... you need to set is the URL of your GraphQL Server, so open src/app/graphql.module.ts....I can not find this file – PureAbap Jul 29 '20 at 10:11
  • Remove apollo-angular and add it again. Past here the full logs of the ng add command that appear in the console. You should have this log : CREATE src/app/graphql.module.ts || PS : Also, what's you Angular version ? – Meadow Jul 29 '20 at 10:21
  • @Meadow I unistalled all npm packages,reinstalled ....created a new project ,gives me this:::ng add apollo-angular Skipping installation: Package already installed An unhandled exception occurred: Cannot find module '@angular-devkit/schematics' Require stack: lar\schematics\install\index.js \@angular-devkit\schematics\tools\export-ref.js \@angular-devkit\schematics\tools\index.js \@angular\cli\utilities\json-schema.js \@angular\cli\models\command-runner.js \@angular\cli\lib\cli\index.js _modules\@angular\cli\lib\init.js _modules\@angular\cli\bin\ – PureAbap Jul 29 '20 at 12:52
  • Is your @angular/cli version is greater than 9 ? Try to delete nodes_modules folder and remove package-lock.json file and then execute : npm i – Meadow Jul 29 '20 at 15:24
  • @Meadow my angular v is the latest,I then try to install ng add apollo-angular ...it says cannot find module '@angular-devkit/schematics'.I install it through the npm..run again,the same problem – PureAbap Jul 29 '20 at 18:45

4 Answers4

6

I had the same issue for '@apollo/client/core'

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

@apollo/client/core

The import from "@apollo/client/core" in apollo.d.ts didn't work properly. Downgrading apollo-angular to 1.10.0 solved the issue. The documentation says it has the support for Angular 10. The import in apollo.d.ts in this version looks like below:

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

This is how the dependencies in my package.json look like:

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

From the apollo-angular#installation doc:

If you are using Apollo-Client v3, please make sure to use apollo-angular@v2

If you are using Apollo-Client v2, please make sure to use apollo-angular@v1 (and for Angular 10 support, make sure to use v1.10.0)

I am using angular v11.0.3. After downgrade apollo-angular to v1.10.0. Compiled successfully.

Remove apollo-angular v2.

npm rm apollo-angular -S

Install 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"
  },
Lin Du
  • 88,126
  • 95
  • 281
  • 483
2

I just had the same issue. Angular 10 doesn't play well with Apollo. Reverting to a previous Angular version should fix it.

You can change your angular version in package.json to something like

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

or whichever you prefer as long it's before Angular 10.

After that delete package-lock.json, delete the node_module and execute

npm i
1

checkout this : https://apollo-angular.com/docs/get-started

npm install apollo-angular @apollo/client graphql