Registry / http-networking / greybel-js

greybel-js

JSON →
library3.7.12jsnpmunverified

Greybel-JS (v3.7.12) is a CLI and library for transpiling, interpreting, and debugging GreyScript, a scripting language for the Grey Hack game. It provides a parser, lexer, compiler, and interpreter with full GreyScript API support. Key differentiators are its ability to manage imports, minimize scripts (up to 40% size reduction), beautify code, and run GreyScript outside the game environment. The package requires Node >=20.17.0 and has optional peer dependencies on React and Monaco editor for the web UI. It offers advanced features like dependency management, environment variables, a REPL, and a debugging UI. Compared to alternatives, Greybel-JS is the main GreyScript toolchain maintained by the community.

npm install greybel-js
INSTALL
IMPORT
SIG · GREYBEL-JS
G
greybel-js
http-networkingjavascriptv3.7.12
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Greybel
✓ import { Greybel } from 'greybel-js'
✗ const greybel = require('greybel-js');
The package is ESM-only since v3; CommonJS require() is not supported.
Transpiler
✓ import { Transpiler } from 'greybel-js'
Named export for transpiling GreyScript into optimized script. Also exported as 'Compiler' in older versions.
Interpreter
✓ import { Interpreter } from 'greybel-js'
✗ import Interpreter from 'greybel-js';
Interpreter is a named export, not a default one. Default import is not available.

Shows how to transpile and interpret GreyScript code using Greybel-JS programmatically.

import { Greybel, Transpiler, Interpreter } from 'greybel-js'; // Example GreyScript source code const source = ` function main() { print("Hello, Grey Hack!"); } main(); `; // Compile/transpile const transpiler = new Transpiler({ source }); const { code, map } = transpiler.transpile(); console.log('Transpiled code:', code); // Or execute with interpreter const interpreter = new Interpreter({ source }); interpreter.on('output', (msg) => console.log('Output:', msg)); interpreter.run(); // Or use CLI: npx greybel-js transpile input.gs -o output.gs
greybel --version
Debug
Known issues
breakingIn Greybel-JS v3, the package switched from CommonJS to ESM-only. Imports using require() will fail with MODULE_NOT_FOUND error.
fix
Use import syntax instead of require(). Update tsconfig.json to target ESNext or use dynamic import for CJS projects.
affects: >=3.0.0
deprecatedThe export name 'Compiler' is deprecated in v3. It has been renamed to 'Transpiler'.
fix
Use 'Transpiler' instead of 'Compiler' when importing.
affects: >=3.0.0
gotchaThe interpreter's mock environment does not include the full Grey Hack API. Some functions (e.g., file I/O, networking) are stubs and will not behave as in-game.
fix
Always test scripts in-game before relying on interpreter behavior. Use the 'debugger' for more accurate simulation.
affects: *
gotchaMinification can break scripts that rely on certain variable names or dynamic property access. Obfuscated names may conflict with reserved keywords.
fix
Test minified scripts thoroughly. Use the 'beautify' option to revert minification for debugging.
affects: *
deprecatedThe CLI flag '--no-color' has been removed in v3. Use 'NO_COLOR' environment variable instead.
fix
Set process.env.NO_COLOR = '1' or use any standard NO_COLOR support.
affects: >=3.0.0
Errors
Common errors & fixes
Cannot find module 'greybel-js'
Using require() in Node.js with an ESM-only package.
fix
Change to import statement: import { ... } from 'greybel-js'; or use dynamic import: const greybel = await import('greybel-js');
TypeError: greybel_js__WEBPACK_IMPORTED_MODULE_0__.default is not a function
Importing default export instead of named exports.
fix
Use named import: import { Greybel, Transpiler, Interpreter } from 'greybel-js';
error: unknown option '--no-color'
Using deprecated CLI flag removed in v3.
fix
Use environment variable: set NO_COLOR=1 before running the CLI.
Upgrade
Version history
3.7.12latest on npm
Audit
Dependencies
@monaco-editor/loaderoptionalRequired for the web UI editor component when using Greybel in browser mode.
reactoptionalPeer dependency for the web UI; needed if using the React-based editor interface.
react-domoptionalPeer dependency for the web UI; needed alongside react for DOM rendering.
Agent activity
10 hits · last 30 days
node
10
Resources
greybel-js — npm install greybel-js · libregistry