Error: Cannot find module ‘graphql/validation/rules/KnownArgumentNamesRule’

Error: Cannot find module ‘graphql/validation/rules/KnownArgumentNamesRule’


26

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

Error: Cannot find module 'graphql/validation/rules/KnownArgumentNamesRule'
    Require stack:
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modules@apo  
    llofederationdistcompositionvalidatepreNormalizationtagDirective.js    
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modules@apo  
    llofederationdistcompositionvalidatepreNormalizationindex.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modules@apo  
    llofederationdistcompositionvalidateindex.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modules@apo  
    llofederationdistcompositioncomposeAndValidate.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modules@apo  
    llofederationdistcompositionindex.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modules@apo  
    llofederationdistindex.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modulesapol  
    lo-language-serverlibprovidersschemafile.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modulesapol  
    lo-language-serverlibprovidersschemaindex.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modulesapol  
    lo-language-serverlibprojectbase.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modulesapol  
    lo-language-serverlibindex.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollolibcommandsclie  
    ntcodegen.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modules@ocl  
    ifconfiglibplugin.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modules@ocl  
    ifconfiglibconfig.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modules@ocl  
    ifconfiglibindex.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modules@ocl  
    ifcommandlibcommand.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollonode_modules@ocl  
    ifcommandlibindex.js
    - C:UsersMinseoAppDataRoamingnpmnode_modulesapollobinrun
    Code: MODULE_NOT_FOUND

8 Answers
8


34

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

 npm install -g graphql

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.

    – Community
    Bot

    Mar 20, 2022 at 0:37

  • 2

    Does it work if you install it in the repo? some people like to avoid global installs

    – jcollum

    Oct 21, 2022 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.

1

  • That's works for me as well

    – Azhar

    Mar 8 at 13:50


6

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

1

  • For me for apollo/2.33.9 was to call sudo yarn global add apollo. (npm doesn't work) (MACOS)

    – Edi

    Feb 16, 2022 at 20:51


6

install both graphql and apalo globally

npm install -g graphql
npm install -g apollo


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. 🤷‍♂️


1

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


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

1

  • 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.

    – Community
    Bot

    Jun 3, 2022 at 14:18


0

installing graphql globally worked for me. npm i -g graphql

New contributor

Walid CHAYBI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



Leave a Reply

Your email address will not be published. Required fields are marked *