You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用expo-cli浏览器模式运行报错:无法解析../Utilities/Platform模块

解决Expo Web模式下无法解析"../Utilities/Platform"的错误

在使用expo-cli启动浏览器模式时,遇到模块解析错误:

无法从“node_modules\react-native\Libraries\ReactPrivate\ReactNativePrivateInterface.js”中解析“../Utilities/Platform”

解决方案

通过自定义Webpack配置添加别名映射,将缺失的模块指向react-native-web的对应实现:

  1. 在项目根目录新建webpack.config.js文件
  2. 写入以下配置代码:
const createExpoWebpackConfigAsync = require('@expo/webpack-config');

module.exports = async function (env, argv) {
  const config = await createExpoWebpackConfigAsync(env, argv);
  config.resolve.alias['../Utilities/Platform'] =
    'react-native-web/dist/exports/Platform'
  return config;
};
  1. 重新执行expo start --web启动服务即可解决该问题

内容的提问来源于stack exchange,提问作者Beanz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 23:47:02