graphql-yoga: Error: Cannot find module 'graphql-middleware'
I get Error: Cannot find module 'graphql-middleware' after update graphql-yoga 1.16.2 to higher version any idea?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 21
Seems like you should read the docs / changelog.
Ya, I tried. It lead to another issue
It did not work like this on 1.16.2
What worked for me was deleting
yarn.lockand installing again.Same thing for me, definitely some form of dependency bug. Switching back to
graphql-yoga@1.16.2helps.@bmirkalami remove line 1 completely. Node cannot understand that.
@bmirkalami You said you “uncommented” the require syntax. Did you then remove the “import” line in all required files?
Also, are you having the same error as the original issue? Or still have the “Unexpected token import” error? If youre still getting the import error then you are missing an import line somewhere. If its the original issue then YAY, we’re back to the original issue but Im not exactly sure how to help as dependancies can be tricky if they get out of whack, when in doubt delete the
node_modulesfolder andpackage-lock.json/yarn.lockfiles. Then try reinstalling the latestgraphql-yoga. Outside of that Im not sure I can help at the moment.@bmirkalami Please correct me if I’m wrong but it seems like you might be unfamiliar with how to properly use “technically” experimental javascript syntax, like
import. You cannot runnode index.json a file with an import statement. That syntax is not supported in node…yet. You need to compile that code to something node can understand. The most common way to do that is by using https://babeljs.io/. I would suggest looking at babel’s site and on Stack Overflow for more information about how to do this: https://stackoverflow.com/questions/45854169/how-can-i-use-an-es6-import-in-node, but this issue is not the place for that discussion. IMHO It’s defintely worth knowing the babel ecosystem and how to use it properly, a bit confusing at first but makes life MUCH easier in the long run when working in the browser and in node. Good luck! 😉@bmirkalami Usually an “Unexpected token import” points to a problem in the transpile. Are you using babel to transpile ES6/7 code? If not, you’ll need to use
const { GraphQLServer } = require("graphql-yoga");