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

Expo-CLI的Metro工具生成的编译后JavaScript文件存放在什么位置?

Expo 安卓平台Metro打包产物存储路径

开发调试模式

开发模式下Metro默认采用内存打包机制,不会主动将完整bundle持久化写入磁盘,如需导出完整JS文件排查问题,需手动执行导出命令:
npx expo export --dev --dump-sourcemap

  • 执行命令后,产物默认输出到项目根目录的dist文件夹下,安卓端主JS bundle路径为:dist/_expo/static/js/android/index-<随机哈希>.js,同名sourcemap文件也存储在同目录。
  • 如需开启开发模式持久化缓存,可在metro.config.js中添加如下配置,缓存的中间产物将存储在项目根目录.metro/cache路径:
const { getDefaultConfig } = require('expo/metro-config');

const config = getDefaultConfig(__dirname);
config.cacheStores = ({ FileStore }) => [
  new FileStore({
    root: './.metro/cache',
  }),
];

module.exports = config;

生产构建模式

  • 执行本地生产构建expo run:android --variant release时,生成的JS bundle默认存储路径为:android/app/build/generated/assets/createBundleReleaseJsAndAssets/index.android.bundle
  • 也可手动指定产物输出路径执行打包:
    npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output ./android-release.bundle --sourcemap-output ./android-release.bundle.map

依赖语法问题排查提示

拿到bundle和sourcemap文件后,可直接使用source-map-explorer工具定位报错代码对应的原始模块,无需手动遍历bundle内容,执行命令为:npx source-map-explorer <bundle文件路径> <sourcemap文件路径>

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.23 18:45:03