Bytenode
raw JSON → 1.5.7 verified Fri May 01 auth: no javascript
Bytenode is a minimalist bytecode compiler for Node.js that compiles JavaScript code into V8 bytecode, stored as .jsc files, enabling source code protection. Current stable version is 1.5.7, with irregular releases. Key differentiators: it compiles to actual V8 bytecode (not just obfuscation), supports Electron and NW.js, provides both CLI and programmatic API, and has TypeScript type definitions. Known limitations include incompatibility with arrow functions in certain contexts and breaking code that depends on Function.prototype.toString.
Common errors
error Cannot find module 'bytenode' ↓
cause Package not installed or import path incorrect.
fix
Run npm install bytenode and ensure correct import syntax (e.g., import { compileCode } from 'bytenode').
error TypeError: compileCode is not a function ↓
cause Using default import and trying to call it directly.
fix
Use named import: import { compileCode } from 'bytenode'.
error Uncaught Error: The module 'app.jsc' was compiled against a different Node.js version ↓
cause Bytecode is version-specific; compiled on different Node.js major version.
fix
Recompile the .jsc file on the target Node.js version.
Warnings
breaking In Node 10.x, Bytenode does not work in debug mode. ↓
fix Do not use Node 10.x with --inspect flag; upgrade to Node 12+.
breaking Arrow functions (especially async) cause crashes in Puppeteer, Electron, and ndb debugger. ↓
fix Avoid using arrow functions in compiled code; use regular function expressions instead.
breaking Code relying on Function.prototype.toString will break because source code is removed from .jsc files. ↓
fix Replace any usage of .toString() on functions with alternative logic (e.g., store string representation elsewhere).
deprecated bytenode.runBytecode is not deprecated, but compileCode and compileFile may see argument changes in future versions. ↓
fix Watch changelog for updates to the API interface.
Install
npm install bytenode yarn add bytenode pnpm add bytenode Imports
- compileCode wrong
const bytenode = require('bytenode'); bytenode.compileCode(...)correctimport { compileCode } from 'bytenode' - compileFile wrong
const compileFile = require('bytenode/compileFile')correctimport { compileFile } from 'bytenode' - runBytecode
import { runBytecode } from 'bytenode' - default wrong
const bytenode = require('bytenode').defaultcorrectimport bytenode from 'bytenode'
Quickstart
import { compileFile, runBytecode } from 'bytenode';
import fs from 'fs';
// Compile a JavaScript file
await compileFile({ filename: 'app.js', output: 'app.jsc' });
// Read the bytecode file and run it
const bytecode = fs.readFileSync('app.jsc');
runBytecode(bytecode);