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

Expo Web打包失败:无法解析effector/effector-react依赖

解决Expo Web无法解析effector/effector-react依赖的问题
  • 确认依赖安装状态
    打开项目根目录的package.json,检查是否存在effector和effector-react的依赖条目。如果没有,重新执行安装命令:

    npm install effector effector-react
    # 使用yarn的话执行此命令
    yarn add effector effector-react
    

    若已存在这两个依赖,直接删除node_modules和锁文件后重新安装:

    rm -rf node_modules package-lock.json yarn.lock
    npm install
    
  • 自定义Expo Web的Webpack配置
    若上述操作无效,可能是Expo默认Webpack配置未正确解析这两个包。先安装必要依赖:

    npm install --save-dev expo-webpack-config
    

    在项目根目录新建webpack.config.js文件,写入以下内容:

    const createExpoWebpackConfigAsync = require('@expo/webpack-config');
    
    module.exports = async function (env, argv) {
      const config = await createExpoWebpackConfigAsync(env, argv);
      // 扩展解析后缀,确保识别effector相关文件
      config.resolve.extensions.push('.js', '.jsx', '.ts', '.tsx');
      config.resolve.modules.push('node_modules');
      return config;
    };
    
  • 清除Expo缓存
    缓存可能导致依赖解析异常,启动Web服务时添加清除缓存参数:

    npx expo start --web --clear
    
  • 检查版本兼容性
    确认effector和effector-react的版本与当前使用的Expo、React/React Native版本兼容,避免因版本不匹配引发解析失败。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 20:17:33