我正试着得到一个预演库来使用expo/react本地语言
在webpack中使用这个别名可以在网上找到:
// webpack.config.js
const createExpoWebpackConfigAsync = require('@expo/webpack-config');
module.exports = async function(env, argv) {
const config = await createExpoWebpackConfigAsync(env, argv);
config.resolve.alias = {
...config.resolve.alias,
'preact': 'react'
}
return config;
};但在安卓系统上,我得到了一个错误:Unable to resolve "preact" from "node_modules/.../...。
有谁知道如何在网络之外工作,得到同样的别名吗?
发布于 2022-12-01 09:12:24
我无法找到一个解决方案,webpack的别名可以在Android上的Web之外使用。我需要它是因为典型的重复使用的React模块导致的钩子调用无效。
据推测,Yarn工作区也可以修复这个问题,但我无法做到这一点。
我找到的解决方案是更新本地库的devDependencies,这样它们都使用了主项目的dependencies中使用的相同的反应模块。
- app
|
|-- package.json dependency: "react":"18.1.0"
- local_library
|
|-- package.json devDependency:
"react": "file:../../../node_modules/react",https://stackoverflow.com/questions/60918258
复制相似问题