1

I'm trying to run a graphql server in nestjs. I get this error when trying to run this project. Package subpath './express4' is not defined by "exports" in /Users/shehanniwanthaka/WORK/RND/nestjs/graphql-api-test/node_modules/@apollo/server/package.json

my package.json is like this

"dependencies": { "@apollo/server": "^5.0.0", "@nestjs/apollo": "11.0.6", "@nestjs/common": "^11.0.1", "@nestjs/core": "^11.0.1", "@nestjs/graphql": "11.0.6", "@nestjs/platform-express": "^11.0.1", "apollo-server-express": "^3.13.0", "graphql": "^16.11.0", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1" }, 

I found out that @nestjs/common major versions should match the @nestjs/apollo version. So changed the versions to be compatible. I tried removing node_modules folder and refetching dependencies. still same error.

my app.module.ts file

import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo'; import { Module } from '@nestjs/common'; import { GraphQLModule } from '@nestjs/graphql'; import { join } from 'path'; import { TasksModule } from './tasks/tasks.module'; @Module({ imports: [ GraphQLModule.forRoot<ApolloDriverConfig>({ driver: ApolloDriver, autoSchemaFile: join(process.cwd(), 'src/schema.gql'), }), TasksModule ], controllers: [], providers: [], }) export class AppModule { } 

Any solutions?

4
  • 1
    got it solved. had to use "@apollo/server": "^4.12.2". If I read the docs it would have been solved easily. My bad. Commented Sep 27 at 12:09
  • I'm also encountering this error but not sure how deprecating to 4.12.2 is the answer, it seems to be deprecated at the end of the year. Where in the docs is it suggesting to downgrade? Commented Sep 30 at 21:48
  • docs suggest that specific version to install Commented Oct 6 at 4:53
  • I faced the same error but in express. It was due to @apollo/server v5. Fixed it following the latest docs (for apollo express) and suggest you the same. Commented Nov 14 at 18:58

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.