Command-Line Tool (emjs)
A Node.js-like CLI for running JavaScript files and interactive evaluation — built with the C++ standard library only.
Usage
emjs <script.js> # run a file
emjs -h # show help
emjs --help
emjs # interactive REPL (stdin)
Run a script
./build/emjs ./tests/script/types.js
Pipe input
printf '%s\n' '1+2' 'let x=5; x+1;' | ./build/emjs
Interactive REPL
When started without arguments, emjs enters interactive mode:
- Type JavaScript and press Enter to evaluate
- Left / right arrow keys move the cursor
- Up / down arrow keys navigate command history
- Backspace deletes the character before the cursor
- Ctrl+C exits the REPL
Extensions in CLI
The CLI binary binds extension modules at startup based on CMake build flags (BUILD_CONSOLE, BUILD_MATH, etc.), so console.log, Math, and JSON are available out of the box when enabled.
Install to PATH
cmake --install build --prefix /usr/local
export PATH="/usr/local/bin:$PATH"
emjs --help
For embedding Emjs in your own binary instead of using the CLI, see the C++ API page.