Graphql: Cannot find module '@apollo/gateway' or its corresponding type declarations.

Created on 24 Jun 2020  路  30Comments  路  Source: nestjs/graphql

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

There is a problem with dependencies.

node_modules/@nestjs/graphql/dist/interfaces/gql-gateway-module-options.interface.d.ts:1:58 - error TS2307: Cannot find module '@apollo/gateway' or its corresponding type declarations.

1 import { GatewayConfig, ServiceEndpointDefinition } from '@apollo/gateway';
                                                           ~~~~~~~~~~~~~~~~~

node_modules/@nestjs/graphql/dist/interfaces/gql-gateway-module-options.interface.d.ts:2:35 - error TS2307: Cannot find module '@apollo/gateway/src/datasources/types' or its corresponding type declarations.

2 import { GraphQLDataSource } from '@apollo/gateway/src/datasources/types';

Environment


"@nestjs/common": "^7.2.0",
"@nestjs/core": "^7.2.0",
"@nestjs/graphql": "^7.4.5",
"@nestjs/platform-express": "^7.1.2",
"@types/graphql-relay": "^0.6.0",
"apollo-server-express": "^2.15.0",
"graphql": "^15.1.0",
"graphql-tools": "^6.0.10",

Most helpful comment

For nvm

I solved my problem by installing node 14.0.0.

All 30 comments

I don't understand why it doesn't get loaded by Yarn. You have to add @apollo/gateway explicitly as dev dependency to your project.

Same problem here.

@apollo/gateway is not a dependency of apollo-server, apollo-server-express, or apollo-server-core, so it's not going to get loaded into our projects automatically.

@nestjs/graphql depends on @apollo/gateway only as a devDependency. I think this is a bug? Since this downstream package actually appears to be required for builds of projects consuming @nestjs/graphql, it should be either a dependency or peerDependency, or the requirement should be eliminated somehow.

This issue should be fixed in 7.4.6. Let me know if you still face any errors.

@kamilmysliwiec It works properly. Thanks for quick fix!

Thank you @kamilmysliwiec - that's fixed it. :+1:

Hello, sorry to bother @kamilmysliwiec, but it doesn't seems fixed for me in 7.4.6 :/
This is fresh project on Windows. Whether with latest graphql version 15 or stable 14.6.0 it doesn't work out of the box.

image

I have added @apollo/gateway as advised above and it works then :)

Ran into this issue today when checking out code onto a laptop i dont use as often. Fixed by updating Node to latest version, and reinstalling packages.

I had the same issue. I had everything up to date, but my node version was v10.x.x. I need to upgrade my local node version to the latest LTS (v12.18.2) and now it works. Maybe it helps someone.

I can confirm the bug with Node 12 LTS on Archlinux.

This error is back since v7.5.2. v7.5.1 is last working version.

error solved by updating each of these packages
@nestjs/common @nestjs/core @nestjs/platform-express to 7.4.4

For nvm

I solved my problem by installing node 14.0.0.

tha

For nvm

I solved my problem by installing node 14.0.0.

thanks, it works for me

I tried with Node 15.12.0, 14.16.0, and 14.0.0 but I still got the same errors.

This solution solved my errors too

error solved by updating each of these packages
@nestjs/common @nestjs/core @nestjs/platform-express to 7.4.4

Still can replicate by following the Introduction Alternatives guide.
Cloned the repo and got the same error.

@kamilmysliwiec could you check this, please? Thank you!

I was using node version:
FROM node:15.2.0-alpine3.10
changed to
FROM node:14.16.0-alpine3.10

and it worked.

I was using node version:
FROM node:15.2.0-alpine3.10
changed to
FROM node:14.16.0-alpine3.10

and it worked.

Thanks for your reply, and I face the same issue after upgrading the node to 15.x.x. and I downgrade to the following versions now:

node v14.16.1
nom 6.14.12

It works now.

I just got this error when doing a minor upgrade to
"@nestjs/graphql": "^7.10.3"
"apollo-server-express": "^2.22.2"

reinstalled everything, nvm use 14, npm clean-install and it's running again.
Seems to be busted in Node 15

Fresh install on node 15 and latest libs with apollo etc, still get the same error. Fixed by separately installing @apollo/gateway. I assume then this issue has not yet been fixed?

I solved my problem by downgrade version of node to v14.16.1 and delete node_modules folder and install it again in my project it worked now.

It looks like @apollo/gateway is currently unsupported in node >= 15... They have a plan to update the package when node 16 turns LTS. Here for more info.

However, if you are really into making it work in node version >= 15, and If you are in a controlled environment, you can do rm -rf node_modules && yarn --ignore-engines. But again, it's not recommended, but it works if you are, as in my case, doing a side project or something.

Seems relevant to share here: As of the landing of apollographql/federation#713, we're now testing @apollo/gateway with Node.js 16 and since those tests are passing, the latest versions of the @apollo/gateway (0.28.0) and @apollo/federation (0.24.0) packages have just been published with Node.js 16 in their supported engines range for node.

This issue occurs also with node 16

Getting this error with node 16 also, gonna try downgrading to versions 14.16.xxx

Get the same error with NodeJS 16 and the following dependencies.

  "dependencies": {
    "@nestjs/common": "^7.6.15",
    "@nestjs/core": "^7.6.15",
    "@nestjs/graphql": "^7.10.6",
    "@nestjs/platform-express": "^7.6.15",
    "apollo-server": "^2.24.0",
    "apollo-server-express": "^2.24.0",
    "graphql": "^15.5.0",
    "graphql-query-complexity": "^0.8.1",
    "graphql-subscriptions": "^1.2.1",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.0",
    "rxjs": "^6.6.7"
  },

I went back to node LTS (14.17) and it now works as intended!!

I was having this problem while using Node v16.4.2. Problem solved using lts/fermium (v14.17.3)

I fear this issue is not fixed yet, since i'm facing this with what seems to be a up-date version: ^8.0.2
Also my node version should be compatible according to what others said here: v14.16.0
I tried npm and yarn, neither worked. :/

@andersonmadeira Just encountered the same problem

Was this page helpful?
0 / 5 - 0 ratings