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

如何为React Native项目构建Hermes JS发布包?

生成Hermes专属JS包的命令

React Native CLI的bundle命令本身就能生成Hermes兼容的包,只需添加指定参数即可,不需要单独的新命令:

  • 针对Android平台:

    npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ --hermes true
    
  • 针对iOS平台:

    npx react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ios/main.jsbundle --assets-dest ios --hermes true
    

补充说明

  • 核心参数是--hermes true,它会触发CLI用Hermes编译器生成适配的字节码文件(.hbc),同时也会生成对应的JS bundle,满足Hermes运行的需求。
  • 如果你的项目已经在metro.config.js里默认启用了Hermes,直接执行常规的bundle命令也能生成Hermes兼容包,无需额外加参数。
  • 要是你需要单独生成Hermes字节码文件(.hbc),可以直接调用Hermes编译器:
    hermesc -O -output index.android.bundle.hbc index.android.bundle
    
    不过一般情况下,bundle命令会自动完成这一步,没必要手动操作。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 21:08:10