无法 运行 博览会网站
Cannot run expo web
我在尝试 运行 expo web
时遇到错误 'Cannot access __fbBatchedBridgeConfig on web'
我根据 https://github.com/expo/fyi/blob/main/fb-batched-bridge-config-web.md 得到的指示是执行以下操作
删除内部导入
您可以完全删除导入,也可以将内部导入移动到特定于平台的块中:
import getDevServer from "react-native/Libraries/Core/Devtools/getDevServer";
或
let getDevServer = () => { /* no-op */ }
if (Platform.OS !== 'web') {
getDevServer = require("react-native/Libraries/Core/Devtools/getDevServer");
+ }
但是,我不确定在哪里插入这段代码。我试过将它插入我的主页,app.js,但我仍然遇到这个错误。
谁能帮我解决这个问题?
(我使用的是 EXPO 4.13.0、SDK 43 和 react-native 0.64.3)
当您尝试使用 react-native 中的嵌套库时会出现此错误。
在您的项目中使用您的 IDE 专门搜索 react-native/
以查找您导入此类嵌套库的位置。
在那里你可以替换有问题的导入,如:
import example from "react-native/example";
至:
let example = () => { /* no-op */ }
if (Platform.OS !== 'web') {
example= require("react-native/example");
}
您还需要像这样导入平台:
import { Platform } from 'react-native';
但请注意,如果您确实需要使用该库,可能会出现其他错误,因此还要编辑您使用它的位置。
我在尝试 运行 expo web
时遇到错误 'Cannot access __fbBatchedBridgeConfig on web'我根据 https://github.com/expo/fyi/blob/main/fb-batched-bridge-config-web.md 得到的指示是执行以下操作
删除内部导入 您可以完全删除导入,也可以将内部导入移动到特定于平台的块中:
import getDevServer from "react-native/Libraries/Core/Devtools/getDevServer";
或
let getDevServer = () => { /* no-op */ }
if (Platform.OS !== 'web') {
getDevServer = require("react-native/Libraries/Core/Devtools/getDevServer");
+ }
但是,我不确定在哪里插入这段代码。我试过将它插入我的主页,app.js,但我仍然遇到这个错误。
谁能帮我解决这个问题?
(我使用的是 EXPO 4.13.0、SDK 43 和 react-native 0.64.3)
当您尝试使用 react-native 中的嵌套库时会出现此错误。
在您的项目中使用您的 IDE 专门搜索 react-native/
以查找您导入此类嵌套库的位置。
在那里你可以替换有问题的导入,如:
import example from "react-native/example";
至:
let example = () => { /* no-op */ }
if (Platform.OS !== 'web') {
example= require("react-native/example");
}
您还需要像这样导入平台:
import { Platform } from 'react-native';
但请注意,如果您确实需要使用该库,可能会出现其他错误,因此还要编辑您使用它的位置。