命令行界面
可以执行 NJS 脚本开发和调试 从命令行。 命令行实用程序在安装 Linux 软件包,或者在从源构建后。 与在 nginx 中运行的 njs 相比, nginx 对象 (HTTP 和 Stream) 在实用程序中不可用。
$ echo "2**3" | njs -q 8 $ njs >> globalThis global { njs: njs { version: '0.3.9' }, global: [Circular], process: process { argv: [ '/usr/bin/njs' ], env: { PATH: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', HOSTNAME: 'f777c149d4f8', TERM: 'xterm', NGINX_VERSION: '1.17.9', NJS_VERSION: '0.3.9', PKG_RELEASE: '1~buster', HOME: '/root' } }, console: { log: [Function: native], dump: [Function: native], time: [Function: native], timeEnd: [Function: native] }, print: [Function: native] } >>