Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module '@apollo/gateway' or its corresponding type declarations. #992

Closed
piotr-pawlowski opened this issue Jun 24, 2020 · 30 comments

Comments

@piotr-pawlowski
Copy link

piotr-pawlowski commented Jun 24, 2020

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",
@razorness
Copy link

razorness commented Jun 24, 2020

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.

@sgarner
Copy link

sgarner commented Jun 24, 2020

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.

@kamilmysliwiec
Copy link
Member

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

@piotr-pawlowski
Copy link
Author

@kamilmysliwiec It works properly. Thanks for quick fix!

@sgarner
Copy link

sgarner commented Jun 25, 2020

Thank you @kamilmysliwiec - that's fixed it. 👍

@FlxEd
Copy link

FlxEd commented Jun 26, 2020

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 :)

@tbrown19
Copy link

tbrown19 commented Jul 3, 2020

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.

@akucharczyk
Copy link

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.

@esistgut
Copy link

esistgut commented Jul 9, 2020

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

@razorness
Copy link

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

@abosaiftaha
Copy link

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

@htndev
Copy link

htndev commented Nov 20, 2020

For nvm

I solved my problem by installing node 14.0.0.

@trgkyle
Copy link

trgkyle commented Jan 20, 2021

tha

For nvm

I solved my problem by installing node 14.0.0.

thanks, it works for me

@ilkaydnc
Copy link

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

@iamelru
Copy link

iamelru commented Mar 28, 2021

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!

@fabioespinosa
Copy link

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

and it worked.

@jamesweb1
Copy link

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.

@paulhill
Copy link

paulhill commented Apr 8, 2021

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

@stiofand
Copy link

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?

@mrrhak
Copy link

mrrhak commented Apr 22, 2021

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.

@douglas-pires
Copy link

douglas-pires commented Apr 25, 2021

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.

@abernix
Copy link

abernix commented May 3, 2021

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.

@simultsop
Copy link

This issue occurs also with node 16

@aydearcas
Copy link

aydearcas commented May 11, 2021

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

@hantsy
Copy link

hantsy commented May 14, 2021

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

@aydearcas
Copy link

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

@dlvx
Copy link

dlvx commented Jul 11, 2021

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

@andersonmadeira
Copy link

andersonmadeira commented Jul 15, 2021

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. :/

@beyerleinf
Copy link

@andersonmadeira Just encountered the same problem

@kamilmysliwiec
Copy link
Member

#1621 (comment)

@nestjs nestjs locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests