当我尝试通过expo运行react-native项目时,我收到此错误
E:/reacrNative23april/firestoreTester26April/node_modules/react-native/Libraries/StyleSheet/processColor.js
Module not found: Can't resolve '../Utilities/Platform' in 'E:\reacrNative23april\firestoreTester26April\node_modules\react-native\Libraries\StyleSheet'
这似乎是一个常见问题(通过谷歌搜索显而易见),但似乎尚未解决。
此链接上有一些嗡嗡声https://github.com/expo/web-examples/issues/73 ,但解决方案并不明确。
有人经历过并解决过这个问题吗?
更多数据-
- 我的是一个裸露的工作流程项目,带有一些 native 模块,不确定它们是否是问题
- 我尝试删除 node_modules 文件夹并运行
npm install
,但没有成功
最佳答案
react-native 中没有非 native (即 Web)版本的实用程序/平台。
您可以创建一个 webpack.config.js ( expo has a helper for this ) 并为从各种 rn 库中使用的 Utilities/Platform 的相对引用添加一个别名到react-native-web 提供的库中:
const createExpoWebpackConfigAsync = require('@expo/webpack-config');
module.exports = async function (env, argv) {
const config = await createExpoWebpackConfigAsync(env, argv);
// Customize the config before returning it.
// Resolve relative reference ../Utilities/Platform using react-native-web
config.resolve.alias['../Utilities/Platform'] = 'react-native-web/dist/exports/Platform';
return config;
};
关于react-native - 通过expo运行react-native项目网页版的网页版时出错。消息是 - 无法编译/Libraries/StyleSheet/processColor.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67943342/