Graphql: Installation with yarn has type errors and prevents build

Created on 1 Sep 2020  路  8Comments  路  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

Doing yarn add @nestjs/graphql graphql-tools graphql apollo-server-express returns the following error once module added to app.module.ts

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';
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[11:28:05 AM] Found 2 errors. Watching for file changes.

The install works fine with npm.

Expected behavior

Expect build to work without any type errors.

Minimal reproduction of the problem with instructions

Just follow the graphql quickstart with yarn instead of npm.

Environment


Nest version: 7.5.1

For Tooling issues:
- Node version: v10.20.1
- Platform:  macos latest

Others:
- yarn: 1.22.4

needs clarification

Most helpful comment

faced the same issue too under node v15.11.0 (due to node 15 is only supported in M1)
solved it by yarn add --dev --ignore-engines @apollo/gateway

All 8 comments

Can be fixed with
yarn add --dev @apollo/gateway
but still looks like a bug

I can't reproduce it with yarn v1.22.5 and @nestjs/[email protected]. Can you test with the latest versions?

Still seeing the same error with both updated.

Can you please provide a minimum reproduction repository? Can you paste your tsconfig here?

{
  "compilerOptions": {
    "module": "commonjs",
    "resolveJsonModule": true,
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  },
  "exclude": ["client", "src/dispatcher/types"]
}

Same issue just generated new nestjs project and install the graphql module as described.

Nodejs Version: v10.23.0

tsconfig:

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  }
}

Update:

Installed nodejs v12.20.0, removed node_modules and install ALL dependencies again, WORKED. Apollo-Gateway isn't compatible with node10.

Installation logs, on node10

info @apollo/[email protected]: The engine "node" is incompatible with this module. Expected version ">=12.13.0". Got "10.23.0"

faced the same issue too under node v15.11.0 (due to node 15 is only supported in M1)
solved it by yarn add --dev --ignore-engines @apollo/gateway

Was this page helpful?
0 / 5 - 0 ratings