aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.43k stars 2.13k forks source link

Uncaught Error: Cannot use e "__Schema" from another module or realm. #6865

Closed codemaster08240328 closed 5 months ago

codemaster08240328 commented 4 years ago

Describe the bug Uncaught Error: Cannot use e "__Schema" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules directory. If different versions of "graphql" are the dependencies of other relied on modules, use "resolutions" to ensure only one version is installed.

To Reproduce aws-amplify: ^3.0.23 react-app-rewired: ^2.1.6

yarn: 1.22.5 node: 12.10.0

when I run yarn start ( react-app-rewired start), it throws the above error.

Expected behavior A clear and concise description of what you expected to happen.

My package.json

{
  "name": "isomorphic",
  "version": "3.0.6",
  "private": true,
  "dependencies": {
    "@amcharts/amcharts4": "^4.9.34",
    "@ant-design/compatible": "^1.0.2",
    "@ant-design/icons": "^4.2.2",
    "@casl/ability": "^4.1.5",
    "@casl/react": "^2.1.1",
    "@glidejs/glide": "^3.4.1",
    "@redq/js-info-bubble": "^0.8.1",
    "@uppy/core": "^1.11.0",
    "@uppy/dropbox": "^1.4.7",
    "@uppy/google-drive": "^1.5.7",
    "@uppy/instagram": "^1.4.7",
    "@uppy/react": "^1.8.0",
    "@uppy/tus": "^1.6.0",
    "antd": "^4.3.4",
    "antd-local-icon": "^0.1.3",
    "auth0-lock": "^11.24.2",
    "aws-amplify": "^3.0.23",
    "card-react": "^1.2.7",
    "chart.js": "^2.9.3",
    "classnames": "^2.2.6",
    "clone": "^2.1.2",
    "d3-shape": "^1.3.7",
    "date-fns": "^2.15.0",
    "enzyme-adapter-react-16": "^1.15.2",
    "enzyme-react-intl": "^2.0.6",
    "express": "^4.17.1",
    "firebase": "^7.15.1",
    "formik": "^2.1.4",
    "frappe-charts": "^1.5.0",
    "fuse.js": "^6.0.4",
    "gaussian": "^1.1.0",
    "globalize": "^1.5.0",
    "google-maps-react": "^2.0.6",
    "history": "^5.0.0",
    "js-rich-marker": "^1.1.2",
    "jwt-decode": "^2.2.0",
    "leaflet": "^1.6.0",
    "lodash": "^4.17.15",
    "moment": "^2.27.0",
    "node-sass": "^4.14.1",
    "nprogress": "^0.2.0",
    "prop-types": "^15.7.2",
    "randomcolor": "^0.6.2",
    "react": "^16.13.1",
    "react-addons-shallow-compare": "^15.6.2",
    "react-awesome-query-builder": "^2.1.9",
    "react-beautiful-dnd": "^13.0.0",
    "react-big-calendar": "^0.25.0",
    "react-chartjs-2": "^2.9.0",
    "react-codemirror": "^1.0.0",
    "react-count-down": "^1.2.1",
    "react-credit-cards": "^0.8.3",
    "react-csv": "^2.0.3",
    "react-custom-scrollbars": "^4.2.1",
    "react-dates": "^21.8.0",
    "react-dnd": "^11.1.3",
    "react-dnd-html5-backend": "^11.1.3",
    "react-dom": "^16.13.1",
    "react-drawer": "^1.3.4",
    "react-dropzone-component": "^3.2.0",
    "react-element-resize": "^0.2.3",
    "react-error-overlay": "^6.0.7",
    "react-flexbox-grid": "^2.1.2",
    "react-flip-move": "^3.0.4",
    "react-ga": "^3.1.2",
    "react-google-charts": "^3.0.15",
    "react-grid-layout": "^0.18.3",
    "react-highlight-words": "^0.16.0",
    "react-icons": "^3.10.0",
    "react-id-swiper": "^3.0.0",
    "react-image-gallery": "^1.0.8",
    "react-instantsearch": "4.3.0",
    "react-intl": "^4.6.9",
    "react-loadable": "^5.5.0",
    "react-motion-drawer": "^3.1.0",
    "react-perfect-scrollbar": "^1.5.8",
    "react-placeholder": "^4.0.3",
    "react-quill": "^1.3.5",
    "react-redux": "^7.2.0",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "react-router-redux": "^4.0.8",
    "react-rrule-generator": "^1.2.0",
    "react-scripts": "^3.4.1",
    "react-sidebar": "^3.0.2",
    "react-speech-recognition": "^2.0.4",
    "react-tag-input": "^6.4.3",
    "react-throttle": "^0.3.0",
    "react-trend": "^1.2.5",
    "react-vis": "^1.11.7",
    "react-youtube": "^7.11.2",
    "recharts": "^1.8.5",
    "redux": "^4.0.5",
    "redux-devtools": "^3.5.0",
    "redux-devtools-dock-monitor": "^1.1.3",
    "redux-devtools-log-monitor": "^1.4.0",
    "redux-logger": "^3.0.6",
    "redux-saga": "^1.1.3",
    "redux-saga-firebase": "^0.15.0",
    "redux-thunk": "^2.3.0",
    "reselect": "^4.0.0",
    "rheostat": "^4.1.1",
    "rich-marker": "^0.0.1",
    "rrule": "^2.6.4",
    "styled-components": "^5.1.1",
    "styled-theme": "^0.3.3",
    "swiper": "^5.4.5"
  },
  "devDependencies": {
    "babel-plugin-import": "^1.13.0",
    "customize-cra": "^1.0.0",
    "enzyme": "^3.11.0",
    "enzyme-to-json": "^3.5.0",
    "react-app-rewired": "^2.1.6",
    "redux-devtools-extension": "^2.13.8",
    "redux-mock-store": "^1.5.4"
  },
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "serve": "serve -s build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Any Idea?

codemaster08240328 commented 4 years ago

Here is the screenshot which shows node module packages. https://share.getcloudapp.com/qGuvj7Zp

heitorlessa commented 4 years ago

Same here when using Gatsby, and I can reproduce the issue by upgrading gatsby to 2.24.77 as my docs build are now failing -- It appears that Amplify is requiring an older version of graphql client while other libs like gatsby are requiring a more up-to-date minor version.

$ aws-lambda-powertools-python@ /Users/lessa/DEV/aws-lambda-powertools-python/docs: npm ls graphql
├─┬ aws-amplify@3.3.3
│ ├─┬ @aws-amplify/api@3.2.6
│ │ └─┬ @aws-amplify/api-graphql@1.2.6
│ │   └── graphql@14.0.0 <-- HERE
│ └─┬ @aws-amplify/pubsub@3.2.4
│   └── graphql@14.0.0 
└─┬ gatsby@2.24.77
  ├─┬ gatsby-cli@2.12.107
  │ └─┬ gatsby-recipes@0.2.31
  │   └── UNMET PEER DEPENDENCY graphql@14.7.0  <-- HERE
  ├─┬ gatsby-plugin-page-creator@2.3.32
  │ └── graphql@14.7.0 
  └── UNMET PEER DEPENDENCY graphql@14.7.0 
mauerbac commented 3 years ago

Sorry for the delay here. Will add urgency to the PR here. Thank you

chrisbonifacio commented 5 months ago

Closing this as graphql has since been upgraded and this is no longer reproducible in Gen 2.

If anyone runs into a similar issue with Amplify Gen 2, please open a new issue with new reproduction steps.