Skip to main content
Get QuickJS-ng running on your system and execute your first JavaScript code.

Installation

1

Install QuickJS-ng

Choose your preferred installation method:
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 qjs command:
Output:

Interactive REPL

QuickJS includes an interactive Read-Eval-Print Loop (REPL) for experimenting with JavaScript:
Try some expressions in the REPL:
Press Ctrl+D or type .exit to exit the REPL.

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

Output:
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

Output:
For simpler embedding, use qjs -c to create standalone executables. See Standalone Executables.

Using the Standard Library

QuickJS includes optional standard library modules for file I/O and system operations:
Run with the --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

Make sure the QuickJS binaries are in your PATH:
Or install to a system directory:
When importing modules, use relative paths starting with ./ or ../:
If you encounter build errors on macOS, ensure you have Command Line Tools installed: