Installation
1
Install QuickJS-ng
Choose your preferred installation method:
- From Source
- Pre-built Binaries
- Using jsvu
2
Verify Installation
Check that QuickJS is installed correctly:You should see output like:
Your First Script
1
Create a JavaScript file
Create a file called
hello.js:hello.js
2
Run the script
Execute your script with the Output:
qjs command:Interactive REPL
QuickJS includes an interactive Read-Eval-Print Loop (REPL) for experimenting with JavaScript:Using Modules
QuickJS supports ES6 modules out of the box.1
Create a module
Create
math.js:math.js
2
Import and use the module
Create
app.js:app.js
3
Run as a module
QuickJS automatically detects modules when you use
import or export syntax, so the --module flag is optional in most cases.Embedding QuickJS in C
QuickJS is designed to be embedded in C/C++ applications. Here’s a minimal example:1
Create a C file
Create
embed.c:embed.c
2
Compile and run
Using the Standard Library
QuickJS includes optional standard library modules for file I/O and system operations:--std flag to enable these modules:
The standard library modules are not loaded by default to keep the engine lightweight. Use
--std when you need file I/O or OS features.Next Steps
Core Concepts
Learn about runtimes, contexts, and memory management
API Reference
Explore the complete C API documentation
CLI Tools
Master the qjs and qjsc command-line tools
Examples
See practical examples and tutorials
Common Issues
Command not found: qjs
Command not found: qjs
Make sure the QuickJS binaries are in your PATH:Or install to a system directory:
Module not found errors
Module not found errors
When importing modules, use relative paths starting with
./ or ../:Compilation errors on macOS
Compilation errors on macOS
If you encounter build errors on macOS, ensure you have Command Line Tools installed: