티스토리 뷰

현상

  • 패키지 매니저는 yarn 사용 중, apollo 버전 ^2.30.1, graphql 버전 ^15.3.0
  • apollo client로 codegen 하는 스크립트를 실행하였더니, graphql 인스턴스가 중복됐다는 에러가 나온다.
Error: Cannot use GraphQLSchema "[object GraphQLSchema]" 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.

    https://yarnpkg.com/en/docs/selective-version-resolutions

    Duplicate "graphql" modules cannot be used at the same time since 
    different
    versions may have different capabilities and behavior. The data from one
    version used in the function from another could produce confusing and
    spurious results.

해결

시도해본 방법은

  • 프로젝트 전체의 노드 모듈 전부 삭제 후 재설치
  • 프로젝트 전체의 노드 모듈 전부 삭제 후 package.json에 resolution 추가해서 버전 고정
  • npm dedupe 로 디펜던시 정리 (npm이 깔려있긴 하니까 혹시)

전부 안되다가 패키지 설치할 때 워닝에서 apollo peer dependency 워닝이 많이 떠서 패치 버전 하나 올렸더니 해결됨...... (2.30.1 -> 2.30.2)

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함