24

When I run the command apollo client:codegen the following error comes up :

Error: Cannot find module 'graphql/validation/rules/KnownArgumentNamesRule'
    Require stack:
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\@apo  
    llo\federation\dist\composition\validate\preNormalization\tagDirective.js    
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\@apo  
    llo\federation\dist\composition\validate\preNormalization\index.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\@apo  
    llo\federation\dist\composition\validate\index.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\@apo  
    llo\federation\dist\composition\composeAndValidate.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\@apo  
    llo\federation\dist\composition\index.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\@apo  
    llo\federation\dist\index.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\apol  
    lo-language-server\lib\providers\schema\file.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\apol  
    lo-language-server\lib\providers\schema\index.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\apol  
    lo-language-server\lib\project\base.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\apol  
    lo-language-server\lib\index.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\lib\commands\clie  
    nt\codegen.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\@ocl  
    if\config\lib\plugin.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\@ocl  
    if\config\lib\config.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\@ocl  
    if\config\lib\index.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\@ocl  
    if\command\lib\command.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\node_modules\@ocl  
    if\command\lib\index.js
    - C:\Users\Minseo\AppData\Roaming\npm\node_modules\apollo\bin\run
    Code: MODULE_NOT_FOUND
NeERAJ TK
  • 2,447
  • 1
  • 11
  • 25
Minseo Lee
  • 240
  • 1
  • 2
  • 5

7 Answers7

31

Downgrading does not help. But installing graphql globally seem to solve the issue.

 npm install -g graphql
NeERAJ TK
  • 2,447
  • 1
  • 11
  • 25
Lam Tung
  • 319
  • 3
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 20 '22 at 00:37
  • 2
    Does it work if you install it in the repo? some people like to avoid global installs – jcollum Oct 21 '22 at 21:21
8

This is a known issue with apollo. I followed the suggestion to downgrade to node v14.17.5, and everything worked.

Heath Borders
  • 30,998
  • 16
  • 147
  • 256
6

You only have to install apollo(yarn add apollo) and fix the problem

Lance Kind
  • 949
  • 12
  • 32
  • For me for apollo/2.33.9 was to call sudo yarn global add apollo. (npm doesn't work) (MACOS) – Edi Feb 16 '22 at 20:51
5

Very annoying issue, I installed graphql and apollo globally using node v 14. At the end this worked for me: https://github.com/apollographql/apollo-tooling/issues/2415#issuecomment-930173053

Now it works with node v 16 and w/o post install. ‍♂️

Sahil Jaidka
  • 271
  • 1
  • 5
  • 13
4

install both graphql and apalo globally

npm install -g graphql npm install -g apollo

1

Just install appolo into your dev dependencies, e.g yarn add -D apollo and use it like ./node_modules/.bin/apollo client:codegen

Georges Feungap
  • 456
  • 3
  • 8
1

I've tried on a windows PC instead of mac with following versions apollo/2.34.0 win32-x64 node-v10.15.3

That worked for me

CYasitha
  • 11
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 03 '22 at 14:18