Error: Cannot find module 'graphql/validation/rules/PossibleTypeExtensions'

Viewed 6985

I am using the following book to build a MERN stack CRUD application. I'm having trouble installing and running graphql.

https://www.amazon.com/Pro-MERN-Stack-Development-Express-dp-1484243900/dp/1484243900/ref=mt_paperback?_encoding=UTF8&me=&qid= (published in 2019).

When I try to start the server contained in this repo https://github.com/vasansr/pro-mern-stack-2/tree/05.02-graphql-schema-file with the command npm start the app crashes and it returns an

Error: Cannot find module 'graphql/validation/rules/PossibleTypeExtensions'

I then followed some advice from a previous instance of this question on here to npm install karma-sinon-chai for the dependancies. But then I get the following error:

npm WARN apollo-graphql@0.4.4 requires a peer of graphql@^14.2.1 but none is installed. You must install peer dependencies yourself.

2 Answers

For me simply running npm install -g graphql fixed the problem (I had already installed Apollo globally with npm install -g apollo).

As per the error message apollo-graphql required a module from the graphql library validation/rules/PossibleTypeExtentions. The version of graphql I was using, as found by looking in my package.json, was "graphql":"^0.13.2".

I first tried to change this by changing my package.json to "^14.3.1". But after trying to install and run graphql I got the same error messages and when I looked in my package.json it had reverted back to "^0.13.2".

This may have been caused by my package.lock, locking me into that version. I then deleted package.lock, and node_modules folder.

I then ran the command nom install --save graphql@14.3.1, this worked fine.

I then just had to reinstall babel and Apollo-server-express and after this everything worked fine.

Related