Home > other >  Cannot run expo web
Cannot run expo web

Time:12-04

I encounter the error 'Cannot access __fbBatchedBridgeConfig on web' when trying to run expo web

The instructions I got according to https://github.com/expo/fyi/blob/main/fb-batched-bridge-config-web.md was to do the following

Remove internal imports You can remove the import altogether, or you can move an internal import inside of a platform specific block:

import getDevServer from "react-native/Libraries/Core/Devtools/getDevServer";

or

let getDevServer = () => { /* no-op */ }
if (Platform.OS !== 'web') {
  getDevServer = require("react-native/Libraries/Core/Devtools/getDevServer");
  }

However, I'm not sure where to insert this code. I've tried inserting it on my home page, on app.js, and I still encounter this error.

Could anyone help me out on this?

(I'm using EXPO 4.13.0, SDK 43 and react-native 0.64.3)

CodePudding user response:

This error shows when you try to use a nested library from react-native.

Search specifically for react-native/ with your IDE in your project to find where you are importing such nested library. There you can replace the offending import like:

 import example from "react-native/example";

to:

let example = () => { /* no-op */ }
if (Platform.OS !== 'web') {
  example= require("react-native/example");
}

You also need to import Platform like:

import { Platform } from 'react-native';

But note other errors might arise if you DO need to use that library, so also edit where you are using it.

  • Related