Cannot use t "__Schema" from another module or realm

The app works fine on development, but crashes on production. I get the image’s error when I run the app using the following command: expo start --no-dev --minify which I’m not able to fix. I’m using yarn and I already tried using the resolutions feature with no success. I’ve tried using both graphl versions 15.5.0 and 15.4.0 and if I run npm ls graphql I get the next log:

├─┬ @apollo/client@3.3.20
│ ├─┬ @graphql-typed-document-node/core@3.1.0
│ │ └── graphql@15.5.0 deduped
│ ├─┬ graphql-tag@2.12.4
│ │ └── graphql@15.5.0 deduped
│ └── graphql@15.5.0 deduped
└── graphql@15.5.0

So I don’t see where the problem is, unless it’s an issue with another library that I’m not aware of.

Error screen:


  Expo CLI 4.3.5 environment info:
      OS: macOS 11.4
      Shell: 5.8 - /bin/zsh
      Node: 12.16.1 - /usr/local/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 7.6.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
      CocoaPods: 1.10.1 - /usr/local/bin/pod
      iOS SDK:
        Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
      Android SDK:
        API Levels: 28, 29, 30
        Build Tools: 28.0.3, 29.0.2, 30.0.0
        System Images: android-24 | Google Play Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
      Android Studio: 4.0 AI-193.6911.18.40.6514223
      Xcode: 12.5/12E262 - /usr/bin/xcodebuild
      expo: ~40.0.0 => 40.0.1 
      react: 16.13.1 => 16.13.1 
      react-dom: 16.13.1 => 16.13.1 
      react-native: => 0.63.2 
      react-native-web: ~0.13.12 => 0.13.18 
      expo-cli: 4.3.5
    Expo Workflow: managed

Ok, I found the cause of the issue.

That file is part of graphql but the problem isn’t within graphl but expo. As you may see in the image above it validates which is the env in order to return a given instanceOf function. What happens is that process.env.NODE_ENV is undefined when running expo publish or doing a production build. The weird part is that if I log process.env it logs the following object:

Object {
  "env": Object {
    "NODE_ENV": "production",

And if I log process.env.NODE_ENV it logs undefined.

What can I do to solve this?

sorry can you point to what expo is doing that is not what you expect it to do that you think breaks the usage of this library?

What if you log process.env.env.NODE_ENV? Based on what you are saying it looks like there might be an extra layer of nesting that shouldn’t be there.

Sorry I added that. console.log({ env: process.env })

process.env.NODE_ENV should not be undefined

it is always defined. see the code that sets it up: react-native/setUpGlobals.js at dc80b2dcb52fadec6a573a9dd1824393f8c29fdc · facebook/react-native · GitHub

also try a minimal app that just prints the NODE_ENV value

Then, why is it undefined when I try to log it?

maybe you have a babel plugin that redefines it or something? it’s hard to know unless you provide a minimal reproducible example

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.