Unable to resolve module 'module://graphql/language/parser.js'

Viewed 4167

I am trying to make a React Native TypeScript project on Snack Expo. Although I have already added graphql in the package.json as well as the types file, I still get this error :

Device: (1:8434) Unable to resolve module 'module://graphql/language/parser.js'
  Evaluating module://graphql/language/parser.js
  Evaluating module://graphql-tag.js
  Evaluating module://graphql/loadCountries.tsx.js
  Evaluating module://App.tsx.js
  Loading module://App.tsx

How can I fix this? I am not using an JS Files. Here's the link to the expo:

https://snack.expo.io/qYOFLsmjv

2 Answers

In my case I install graphql to made this error go away. Also I used graphql-request package which by default do not install graphql as a dependency so I added it this way.

npm install graphql

This issue is comes when you use import gql from 'graphql-tag'. Honestly I don't know why graphql-tag not working in snack.expo.io, however it is working on react-native project.

But I have found the solution. I have added "@apollo/client": "3.3.6" (use latest version) as dependency in package.json and then imported gql from @apollo/client like this :

import { gql } from '@apollo/client';

And it worked.

Related