How to Fix Hermes Errors in React Native
Hermes is the JavaScript engine used by React Native to execute JavaScript code in your application. It's designed specifically for React Native and can improve startup performance, reduce memory usage, and optimize application size.
However, like any part of the development environment, Hermes can introduce problems.
You might encounter an application that crashes immediately after launching, a build that fails during JavaScript compilation, an error involving incompatible bytecode, or a runtime exception that only appears in release mode.
Sometimes the problem starts after upgrading React Native, changing dependencies, updating an Expo SDK, or publishing an over-the-air update.
The frustrating part is that not every error mentioning Hermes actually originates from Hermes itself.
Before changing your JavaScript engine or reinstalling your entire project, let's go through the most common problems and how to troubleshoot them.
1. Check whether Hermes is actually enabled
Before troubleshooting Hermes-specific errors, confirm that your application is using Hermes.
For React Native applications, you can check this directly from JavaScript:
const isHermesEnabled = () => {
return !!global.HermesInternal;
};
console.log('Hermes enabled:', isHermesEnabled());
If the result is true, Hermes is available in your JavaScript runtime.
If it's false, your application may be using another JavaScript engine.
Keep in mind that this check confirms the presence of the Hermes runtime. It doesn't prove that every part of your build is using the expected compiler or bytecode configuration.
For modern React Native projects, Hermes is enabled by default.
If you're using an older project or have explicitly changed the JavaScript engine configuration, inspect your native project settings before assuming Hermes is active.
You can find more information in the official React Native Hermes documentation.
2. Fix Hermes bytecode version errors
One of the more serious Hermes problems occurs when the bytecode generated during compilation is incompatible with the Hermes runtime executing it.
You might encounter an error similar to:
Compiling JS failed.
Wrong bytecode version.
Expected XX but got YY.
This can cause the application to crash immediately during startup.
Why does this happen?
Hermes compiles JavaScript into its own bytecode format. The runtime needs to understand the bytecode generated by the compiler.
If the compiler and runtime versions are incompatible, the application cannot execute the bundle correctly.
This can happen after:
- Updating React Native without rebuilding the native application.
- Using incompatible Hermes compiler and runtime versions.
- Publishing an OTA update for a different native runtime.
- Mixing generated bundles from different build environments.
What to do
First, check your React Native version:
npm ls react-native
If you use Yarn:
yarn why react-native
For React Native 0.69 and later, Hermes is bundled with React Native. The recommended approach is to use the Hermes version supplied with your installed React Native version rather than manually installing an unrelated Hermes version.
If you recently upgraded React Native, rebuild the native application so that the JavaScript bundle and native runtime are compatible.
For Android:
npm run android
For iOS:
npm run ios
If you're using Expo with EAS Build, create a new native build after changing the React Native version or JavaScript engine configuration.
Important: If you're using OTA updates, check your runtime version configuration as well. An update containing bytecode generated for a different Hermes version may be incompatible with an already-installed native application.
Expo documents this behavior in its Hermes guide.
Don't attempt to solve bytecode incompatibility by randomly upgrading or downgrading Hermes packages. First identify which compiler and runtime your application is actually using.
3. Fix applications that crash immediately after launching
Sometimes the build completes successfully, but the application crashes as soon as you open it.
You might see messages such as:
FATAL EXCEPTION: mqt_native_modules
Or:
Unhandled JS Exception
js engine: hermes
These messages indicate that an exception occurred while the application was executing JavaScript or interacting with native modules.
However, they don't automatically mean Hermes is broken.
The actual cause could be:
- A JavaScript exception during application initialization.
- A native module that isn't properly configured.
- An incompatible third-party dependency.
- A problem introduced by a recent React Native upgrade.
- A difference between development and release configurations.
What to do
Start by collecting the actual runtime error.
On Android, use:
adb logcat
For more focused output, you can filter for React Native and application errors:
adb logcat *:E
On iOS, inspect the application logs through Xcode's debug console.
Look for the first meaningful exception before the application terminates.
If the application only crashes in release mode, compare its behavior with a debug build.
For Android:
npm run android -- --mode="release"
For iOS:
npm run ios -- --mode="Release"
If the problem appears only in release mode, investigate differences in bundling, minification, native configuration, and dependencies.
Don't immediately disable Hermes. First determine whether the crash originates from JavaScript, a native module, or the engine itself.
4. Fix Hermes errors that appear only in release builds
An application may work perfectly in development but crash after generating a production build.
This is particularly frustrating because the development environment doesn't reproduce the problem.
One reason is that release builds use a different execution and bundling process.
With Hermes, JavaScript is compiled into bytecode during the build process. Release builds may also use optimizations and production-specific configuration that aren't present in development.
For example, you might encounter an error involving an undefined property, an unexpected runtime exception, or a crash that only happens after installing the release APK.
What to do
First, reproduce the problem in a release build rather than relying exclusively on Metro's development server.
Then inspect the logs for the original exception.
If the stack trace contains short function names and bytecode offsets, you may need to symbolicate it.
For example:
p@1:132161
p@1:132084
f@1:131854
These entries aren't particularly useful without the corresponding source map.
React Native provides metro-symbolicate to translate Hermes stack traces into more meaningful source locations.
A typical command looks like this:
npx metro-symbolicate path/to/source.map < stacktrace.txt
Replace the paths with the actual locations of your source map and stack trace.
Make sure you're using the source map generated by the same build as the crash. A source map from a different application version may produce incorrect results.
For more information, see the official React Native release build debugging guide.
5. Fix errors after upgrading React Native
Upgrading React Native can introduce compatibility problems involving Hermes and other native dependencies.
For example, you might update React Native, install the new JavaScript dependencies, and then encounter errors during compilation or application startup.
This can happen because React Native and its bundled Hermes version are developed and released together.
Starting with React Native 0.69, each React Native release includes its corresponding Hermes version.
This means that manually changing Hermes independently of React Native can introduce compatibility problems.
What to do
First, check which React Native version is installed:
npm ls react-native
Then inspect your package.json for unexpected Hermes-related dependencies or overrides.
If you have manually added a separate Hermes package version, check whether it's actually required by your project.
For modern React Native projects, you generally shouldn't need to install an unrelated Hermes version manually.
Next, reinstall your JavaScript dependencies using your project's package manager.
For npm projects:
npm install
For Yarn projects:
yarn install
If you're using iOS, reinstall the native dependencies when necessary:
cd ios
bundle exec pod install
Finally, rebuild the application.
Don't assume that a successful JavaScript dependency installation means the native project has been updated correctly.
6. Fix Hermes configuration problems in Expo projects
If you're using Expo, Hermes is also the default JavaScript engine for modern projects.
However, problems can occur when changing engine configuration or publishing updates to existing applications.
For example, you might have an existing application built with one JavaScript engine and later change the configuration to use another.
In your app.json, the configuration can look like this:
{
"expo": {
"jsEngine": "hermes"
}
}
If you want to use JavaScriptCore instead, you can configure:
{
"expo": {
"jsEngine": "jsc"
}
}
You can also configure the engine separately for iOS and Android when needed.
What to do
First, verify the engine configuration in your Expo project.
Then determine whether the problem appeared after changing the engine or upgrading your Expo SDK.
If you changed the JavaScript engine, you need a new native build. An OTA update cannot replace the JavaScript engine already included in the installed native application.
If you're using EAS Update, also inspect your runtimeVersion configuration.
Your updates must target a compatible native runtime. Otherwise, an existing application may receive JavaScript or Hermes bytecode that its installed native runtime cannot execute.
Don't regenerate your entire native project or change multiple configuration settings before identifying which part of the Expo workflow is failing.
The official Expo Hermes guide explains the engine configuration and compatibility considerations.
7. Fix problems caused by third-party native modules
Not every Hermes-related crash is caused by Hermes itself.
A third-party React Native library may have native code that doesn't work correctly with your current React Native version, architecture, or configuration.
For example, an application may crash after installing a new dependency, even though the same application worked before.
This can happen with libraries that depend on JSI, native modules, or other parts of the React Native runtime.
What to do
Start by identifying whether the issue appeared immediately after installing or upgrading a dependency.
Check the library's documentation for compatibility requirements.
Then inspect its installed version:
npm ls package-name
Replace package-name with the actual dependency.
Check whether the library supports your installed React Native version and architecture.
If the problem started after an update, temporarily testing the previous compatible version may help confirm whether that dependency introduced the issue.
For iOS, remember that native dependency changes may require:
cd ios
bundle exec pod install
For Android, you may need to rebuild the native application.
Avoid assuming that disabling Hermes is the correct solution. A native module compatibility issue may still exist even if you switch JavaScript engines.
8. When should you disable Hermes?
Disabling Hermes can be useful as a diagnostic step.
For example, if you suspect that a particular issue is related to Hermes, temporarily switching to JavaScriptCore can help determine whether the behavior changes.
However, this should be treated as a test, not an automatic fix.
If your project supports JavaScriptCore, you can configure it in Expo:
{
"expo": {
"jsEngine": "jsc"
}
}
For bare React Native projects, the configuration depends on the React Native version and platform.
After changing the engine, you must rebuild the native application.
If the application works with JavaScriptCore but crashes with Hermes, you've narrowed down the problem.
You still need to investigate the underlying cause, which could involve an unsupported library, a runtime incompatibility, or an issue in the JavaScript code.
Switching engines without understanding the problem can simply hide the original issue.
9. When none of these solutions work, collect the right information
If you've tried the relevant troubleshooting steps and the problem persists, stop making random configuration changes.
At this point, you need enough information to identify the actual failure.
Collect:
- Your React Native or Expo SDK version.
- Your Hermes configuration.
- Your operating system and target platform.
- Whether the problem happens in debug, release, or both.
- The complete error message and relevant stack trace.
- Whether the problem started after an upgrade or dependency change.
- Any relevant native build output.
- Whether the application uses OTA updates.
Also include the relevant parts of your package.json, app.json, or native configuration when applicable.
If you're dealing with a long error log or several interacting dependencies, this is where FixMyError can help.
Instead of manually sorting through the entire output, you can submit the error together with the relevant technical context. FixMyError analyzes the information to help identify the likely cause and suggest a more targeted solution.
You can try it at FixMyError.
As always, remove API keys, access tokens, private repository URLs, and other sensitive information before sharing logs.
Final thoughts
Hermes problems can be difficult to troubleshoot because the JavaScript engine interacts with React Native, native dependencies, build configuration, and the application's runtime environment.
An incompatible bytecode version, a release-only crash, or a third-party native module can all produce errors that appear to originate from Hermes.
The most important thing is to identify which part of the application is actually failing.
Check the runtime and compiler versions, inspect the original error, verify your native configuration, and rebuild when necessary.
Don't immediately disable Hermes or reinstall everything.
A targeted fix based on the actual error will usually save you much more time than repeatedly changing your development environment.
Top comments (0)