{"id":25658,"library":"greybel-js","title":"Greybel-JS","description":"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.","status":"active","version":"3.7.12","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/ayecue/greybel-js","tags":["javascript","greybel","greyscript","greyhack","grey hack","grey","hack","miniscript","unity"],"install":[{"cmd":"npm install greybel-js","lang":"bash","label":"npm"},{"cmd":"yarn add greybel-js","lang":"bash","label":"yarn"},{"cmd":"pnpm add greybel-js","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for the web UI editor component when using Greybel in browser mode.","package":"@monaco-editor/loader","optional":true},{"reason":"Peer dependency for the web UI; needed if using the React-based editor interface.","package":"react","optional":true},{"reason":"Peer dependency for the web UI; needed alongside react for DOM rendering.","package":"react-dom","optional":true}],"imports":[{"note":"The package is ESM-only since v3; CommonJS require() is not supported.","wrong":"const greybel = require('greybel-js');","symbol":"Greybel","correct":"import { Greybel } from 'greybel-js'"},{"note":"Named export for transpiling GreyScript into optimized script. Also exported as 'Compiler' in older versions.","symbol":"Transpiler","correct":"import { Transpiler } from 'greybel-js'"},{"note":"Interpreter is a named export, not a default one. Default import is not available.","wrong":"import Interpreter from 'greybel-js';","symbol":"Interpreter","correct":"import { Interpreter } from 'greybel-js'"}],"quickstart":{"code":"import { Greybel, Transpiler, Interpreter } from 'greybel-js';\n\n// Example GreyScript source code\nconst source = `\nfunction main() {\n    print(\"Hello, Grey Hack!\");\n}\nmain();\n`;\n\n// Compile/transpile\nconst transpiler = new Transpiler({ source });\nconst { code, map } = transpiler.transpile();\nconsole.log('Transpiled code:', code);\n\n// Or execute with interpreter\nconst interpreter = new Interpreter({ source });\ninterpreter.on('output', (msg) => console.log('Output:', msg));\ninterpreter.run();\n\n// Or use CLI: npx greybel-js transpile input.gs -o output.gs","lang":"typescript","description":"Shows how to transpile and interpret GreyScript code using Greybel-JS programmatically."},"warnings":[{"fix":"Use import syntax instead of require(). Update tsconfig.json to target ESNext or use dynamic import for CJS projects.","message":"In Greybel-JS v3, the package switched from CommonJS to ESM-only. Imports using require() will fail with MODULE_NOT_FOUND error.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use 'Transpiler' instead of 'Compiler' when importing.","message":"The export name 'Compiler' is deprecated in v3. It has been renamed to 'Transpiler'.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Always test scripts in-game before relying on interpreter behavior. Use the 'debugger' for more accurate simulation.","message":"The 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.","severity":"gotcha","affected_versions":"*"},{"fix":"Test minified scripts thoroughly. Use the 'beautify' option to revert minification for debugging.","message":"Minification can break scripts that rely on certain variable names or dynamic property access. Obfuscated names may conflict with reserved keywords.","severity":"gotcha","affected_versions":"*"},{"fix":"Set process.env.NO_COLOR = '1' or use any standard NO_COLOR support.","message":"The CLI flag '--no-color' has been removed in v3. Use 'NO_COLOR' environment variable instead.","severity":"deprecated","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change to import statement: import { ... } from 'greybel-js'; or use dynamic import: const greybel = await import('greybel-js');","cause":"Using require() in Node.js with an ESM-only package.","error":"Cannot find module 'greybel-js'"},{"fix":"Use named import: import { Greybel, Transpiler, Interpreter } from 'greybel-js';","cause":"Importing default export instead of named exports.","error":"TypeError: greybel_js__WEBPACK_IMPORTED_MODULE_0__.default is not a function"},{"fix":"Use environment variable: set NO_COLOR=1 before running the CLI.","cause":"Using deprecated CLI flag removed in v3.","error":"error: unknown option '--no-color'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}