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

React Native使用StyleSheet报错找不到./PlatformColorValueTypes求助

报错原因

该报错是由于项目内react-native核心库与react-native-web的版本不匹配导致,PlatformColorValueTypes是React Native内部模块,版本不匹配时React Native Web无法正常调用该模块,与你写的StyleSheet样式代码无关。

解决步骤

  • 先查看当前安装的两个依赖版本,执行命令:
    npm ls react-native react-native-web
    如果使用yarn包管理器,执行:
    yarn list react-native react-native-web
  • 卸载现有不匹配的版本,安装适配的版本组合即可,稳定适配的组合参考:
    npm install react-native@0.72 react-native-web@0.19
    yarn环境下执行:
    yarn add react-native@0.72 react-native-web@0.19
  • 依赖安装完成后清空项目缓存重启:
    npx react-native start --reset-cache
  • 如果问题仍未解决,删除项目根目录下的node_modules文件夹、package-lock.json文件(yarn环境下删除yarn.lock文件),重新执行npm install或者yarn install安装所有依赖后再启动项目。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.30 12:18:02