缺少反应本机的实用程序/平台

Ste*_*sic 8 react-native expo

我尝试在浏览器模式下运行 expo-cli 。

但有一个错误:

找不到模块:无法解析“.../node_modules/react-native/Libraries/Core/Timers”中的“../../Utilities/Platform”。

我也尝试手动查找该模块,但没有成功。

我该怎么做才能使 expo 客户端在网络浏览器中运行?

Alf*_*nda 5

您还可以配置您的 webpack。您可以使用“expo custom:web”。这将作为开发依赖项安装@expo/webpack-config并创建一个webpack.config.js.

您可以在此配置上定义别名,如下所示:

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
}
Run Code Online (Sandbox Code Playgroud)

这应该可以解决您的问题


小智 1

使用模块解析器插件来解析对 React Native Web 导出的依赖关系可能会对您有所帮助。React-native-viewpager 在解析相对路径时存在问题。请参阅此评论和整个线程: https: //github.com/expo/web-examples/issues/73#issuecomment-621078860和示例存储库: https: //github.com/ricardoribas/expo-react-native-网络

  • 第二个链接不再有效。您能解释一下如何解决这个问题吗? (4认同)