{"id":25043,"library":"bytenode","title":"Bytenode","description":"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.","status":"active","version":"1.5.7","language":"javascript","source_language":"en","source_url":"https://github.com/bytenode/bytenode","tags":["javascript","bytenode","bytecode","v8-snapshots","compile","compiler","typescript"],"install":[{"cmd":"npm install bytenode","lang":"bash","label":"npm"},{"cmd":"yarn add bytenode","lang":"bash","label":"yarn"},{"cmd":"pnpm add bytenode","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for parsing CLI commands (required for CLI usage, optional for programmatic API)","package":"commander","optional":true}],"imports":[{"note":"ESM named import; CJS require works but destructure recommended.","wrong":"const bytenode = require('bytenode'); bytenode.compileCode(...)","symbol":"compileCode","correct":"import { compileCode } from 'bytenode'"},{"note":"File compiling function; direct path import is incorrect.","wrong":"const compileFile = require('bytenode/compileFile')","symbol":"compileFile","correct":"import { compileFile } from 'bytenode'"},{"note":"Executes compiled bytecode buffer.","symbol":"runBytecode","correct":"import { runBytecode } from 'bytenode'"},{"note":"Default export is an object with all functions; directly usable.","wrong":"const bytenode = require('bytenode').default","symbol":"default","correct":"import bytenode from 'bytenode'"}],"quickstart":{"code":"import { compileFile, runBytecode } from 'bytenode';\nimport fs from 'fs';\n\n// Compile a JavaScript file\nawait compileFile({ filename: 'app.js', output: 'app.jsc' });\n\n// Read the bytecode file and run it\nconst bytecode = fs.readFileSync('app.jsc');\nrunBytecode(bytecode);","lang":"typescript","description":"Compiles a JavaScript file to bytecode and then loads and executes the bytecode."},"warnings":[{"fix":"Do not use Node 10.x with --inspect flag; upgrade to Node 12+.","message":"In Node 10.x, Bytenode does not work in debug mode.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Avoid using arrow functions in compiled code; use regular function expressions instead.","message":"Arrow functions (especially async) cause crashes in Puppeteer, Electron, and ndb debugger.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Replace any usage of .toString() on functions with alternative logic (e.g., store string representation elsewhere).","message":"Code relying on Function.prototype.toString will break because source code is removed from .jsc files.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Watch changelog for updates to the API interface.","message":"bytenode.runBytecode is not deprecated, but compileCode and compileFile may see argument changes in future versions.","severity":"deprecated","affected_versions":">=1.3.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run npm install bytenode and ensure correct import syntax (e.g., import { compileCode } from 'bytenode').","cause":"Package not installed or import path incorrect.","error":"Cannot find module 'bytenode'"},{"fix":"Use named import: import { compileCode } from 'bytenode'.","cause":"Using default import and trying to call it directly.","error":"TypeError: compileCode is not a function"},{"fix":"Recompile the .jsc file on the target Node.js version.","cause":"Bytecode is version-specific; compiled on different Node.js major version.","error":"Uncaught Error: The module 'app.jsc' was compiled against a different Node.js version"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}