Download and install
- Installing as a Linux package
- Building from the sources
- Adding QuickJS engine support
- Building njs command-line utility
Installing as a Linux package
For Linux, njs modules packages can be used:
-
nginx-module-njs— njs dynamic modules -
nginx-module-njs-dbg— debug symbols for thenginx-module-njspackage
After package installation, njs dynamic modules need to be loaded with the load_module directive:
load_module modules/ngx_http_js_module.so;
or
load_module modules/ngx_stream_js_module.so;
Building from the sources
The repository with njs sources can be cloned with the following command (requires Git client):
git clone https://github.com/nginx/njs
Then the modules should be compiled from nginx root directory using the --add-module configuration parameter:
./configure --add-module=path-to-njs/nginx
The modules can also be built as dynamic:
./configure --add-dynamic-module=path-to-njs/nginx
Adding QuickJS engine support
Make sure you have built the QuickJS library:
git clone https://github.com/bellard/quickjs cd quickjs CFLAGS='-fPIC' make libquickjs.a
At the module compilation step, also specify the include (-I) and library (-L) paths with the --with-cc-opt= and --with-ld-opt= configuration parameters:
./configure --add-module=path-to-njs/nginx \ --with-cc-opt="-Ipath-to-quickjs" \ --with-ld-opt="-Lpath-to-quickjs"
Building njs command-line utility
To build only the njs command-line utility, run ./configure and make njs commands from njs root directory. After building, the utility is available as ./build/njs.
© 2002-2021 Igor Sysoev
© 2011-2025 Nginx, Inc.
Licensed under the BSD License.
https://nginx.org/en/docs/njs/install.html