Registry / devops / hermes-compiler

hermes-compiler

JSON →
library250829098.0.2jsnpmunverified

The `hermes-compiler` package provides the command-line interface (CLI) for the Hermes JavaScript engine, specifically optimized for React Native applications. Hermes focuses on delivering improved startup time, reduced memory usage, and smaller app sizes by leveraging ahead-of-time (AOT) compilation, which converts JavaScript source code into compact Hermes Bytecode (HBC) during the build process. The package's public versioning (e.g., v0.13.0 for RN 0.75.x) is tightly coupled with React Native releases, ensuring compatibility. While the npm registry shows an internal version like `250829098.0.2`, it's the `v0.x.x` versions that align with React Native support. Hermes is now the default JavaScript engine for React Native, requiring no additional configuration for most projects.

npm install hermes-compiler
INSTALL
IMPORT
SIG · HERMES-COMPILER
H
hermes-compiler
devopsjavascriptv250829098.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

hermes-compiler CLI (npx)
npx hermes-compiler src/index.js -o dist/index.hbc
import { hermesCompiler } from 'hermes-compiler';
This package is a command-line interface tool and does not export JavaScript modules for direct import. Its primary interaction is via `npx` or npm scripts during the build process.
hermes-compiler CLI (direct binary)
./node_modules/.bin/hermes-compiler src/index.js -o dist/index.hbc
const hermesCompiler = require('hermes-compiler');
For environments where `npx` is not available or for direct scripting, the executable can be invoked from the local `node_modules/.bin` directory.
package.json script
{ "scripts": { "compile:hermes": "hermes-compiler src/entry.js -o build/app.hbc" } }
It is commonly integrated into `package.json` scripts to automate the bytecode compilation step within a project's build pipeline.

Demonstrates how to programmatically invoke the `hermes-compiler` CLI using Node.js's `child_process.exec` to compile a simple JavaScript file into Hermes bytecode (.hbc).

import { exec } from 'child_process'; import { promises as fs } from 'fs'; import * as path from 'path'; const sourceCode = `'use strict';\n\nfunction greet(name) {\n console.log('Hello, ' + name + '!');\n}\n\ngreet('Hermes User');\n`; const inputFilePath = path.join(__dirname, 'temp.js'); const outputFilePath = path.join(__dirname, 'temp.hbc'); async function compileWithHermes() { try { await fs.writeFile(inputFilePath, sourceCode); console.log(`Created temporary source file: ${inputFilePath}`); const command = `npx hermes-compiler ${inputFilePath} -o ${outputFilePath}`; console.log(`Executing command: ${command}`); const { stdout, stderr } = await new Promise((resolve, reject) => { exec(command, (error, stdout, stderr) => { if (error) { return reject(error); } resolve({ stdout, stderr }); }); }); console.log('Compilation successful!'); console.log('stdout:', stdout); if (stderr) console.error('stderr:', stderr); console.log(`Hermes bytecode saved to: ${outputFilePath}`); // Clean up temporary files await fs.unlink(inputFilePath); await fs.unlink(outputFilePath); console.log('Cleaned up temporary files.'); } catch (error) { console.error('Hermes compilation failed:', error); if (error.stderr) console.error('Compiler stderr:', error.stderr); } } compileWithHermes();
hermesc --version
Debug
Known issues
breakingThe command-line debugger was removed from `hermes-compiler` in v0.12.0, which may impact workflows relying on CLI-based debugging tools.
fix
Migrate to alternative debugging methods, typically integrated within the React Native development server or IDEs, or use external tools.
affects: >=0.12.0
breakingAs of v0.12.0, React Native now builds Hermes from source. This change simplifies integration for standard React Native users but requires a different approach for developers attempting to build or integrate custom Hermes versions from source.
fix
Consult the official Hermes GitHub repository for updated instructions on building Hermes from source and integrating custom builds into a React Native project.
affects: >=0.12.0
gotchaPrior to v0.12.0, specific `hermes-compiler` versions were often tied to particular React Native versions (e.g., v0.11.0 for RN 0.68.x). Mismatched versions could lead to runtime crashes or unexpected behavior.
fix
Always align your `hermes-compiler` version with the React Native version specified in the release notes or the `react-native-hermes` package.
affects: <0.12.0
breakingThe introduction of the 'Hades' concurrent garbage collector in v0.8.0 significantly altered GC pause times and performance characteristics. While generally an improvement, it could subtly affect applications with extreme performance sensitivities to GC.
fix
Benchmark and profile applications on Hermes v0.8.0+ to understand performance impacts, particularly for CPU-intensive workloads. Consult Hermes documentation on Hades for details.
affects: >=0.8.0
gotchaSome Hermes versions have platform-specific releases or packaging changes (e.g., v0.5.3 for Darwin only, publishing `hermes-runtime-darwin` to CocoaPod instead of `hermes-engine-darwin` to NPM in v0.7.1), which can cause build failures on unsupported platforms or with incorrect dependency configurations.
fix
Ensure the correct `hermes-compiler` or `hermes-engine` variant is used for your target platform and React Native version. Verify platform-specific installation notes carefully.
affects: >=0.5.0
gotchaSupport for ECMAScript features like `WeakRef` and `BigInt` was added in v0.12.0. Using these features with older `hermes-compiler` versions will result in compilation or runtime errors.
fix
Upgrade to `hermes-compiler` v0.12.0 or newer to use `WeakRef` and `BigInt`. For older versions, transpile down these features or avoid them.
affects: <0.12.0
Errors
Common errors & fixes
'hermes-compiler' is not recognized as an internal or external command, operable program or batch file.
The `hermes-compiler` executable is not in the system's PATH, or `npx` cannot find it within `node_modules/.bin`.
fix
Ensure `npm` is correctly installed and `node_modules/.bin` is accessible, or use `npx hermes-compiler` or the full path `./node_modules/.bin/hermes-compiler` to invoke it. For npm scripts, define `"scripts": { "compile": "hermes-compiler ..." }`.
Error: Cannot find module 'hermes-compiler'
Attempting to use `import` or `require` with `hermes-compiler` directly in JavaScript code. This package is a CLI tool, not a JavaScript module for programmatic import.
fix
Do not `import` or `require` `hermes-compiler`. Instead, execute it as a command-line tool using `npx hermes-compiler` or `child_process.exec`/`spawn` if invoked programmatically from Node.js.
HermesVM: Compiling JS failed: ... SyntaxError: ...
The JavaScript source code passed to the Hermes compiler contains syntax errors or uses unsupported language features for the targeted Hermes version.
fix
Review the indicated line and column for syntax errors. Ensure that the JavaScript features used are supported by your `hermes-compiler` version, or transpile down with Babel if necessary.
Release builds fail due to missing hermesc bin on Windows
The `hermes-compiler` package might not ship Windows binaries for all versions or specific React Native setups, leading to build failures.
fix
Check the `hermes-compiler` and React Native release notes for Windows compatibility. Ensure your environment matches the expected setup. In some cases, manual workarounds or specific package versions might be required.
LLVM ERROR: Generating HBC bytecode disabled in Static Hermes
This error can occur when trying to use `hermes` with `Static Hermes` builds in a way that conflicts with its configuration, specifically when attempting to generate bytecode directly when it's disabled.
fix
If using experimental 'Static Hermes' builds, ensure you are invoking the correct executable (e.g., `shermes` instead of `hermes`) and following its specific compilation flags and usage patterns. Refer to the 'Static Hermes' documentation or relevant GitHub discussions.
Upgrade
Version history
250829098.0.2latest on npm
Audit
Dependencies
react-nativerequiredHermes is primarily developed and optimized for use as the JavaScript engine within React Native applications. Its compiler is integrated into the React Native build pipeline.
noderequiredThe `hermes-compiler` is a command-line interface (CLI) tool that runs in a Node.js environment, typically invoked via `npx` or `npm scripts`.
Agent activity
37 hits · last 30 days
node
36
Amazon
1
Resources