Getting: unknown directive "js_import" when njs used with Nginx

Viewed 4465

I am making the following statement in the Nginx conf:

js_import http.js;

But it seems to give me unknown directive "js_import"

I have verified whether the njs is installed. I can seem to get into the cli. Version of njs is 0.3.9

The below statement seems to be working and is placehttp block:

js_include http.js

This also seem to work and is placed in the server block inside http block:

js_content hello

Nginx seems to be the latest version.

I cannot seems to find what I am missing here.

Any help is greatly appreciated.

2 Answers

reading this and putting

load_module /usr/lib/nginx/modules/ngx_http_js_module.so;

at the top of my nginx.conf solved my problem you may need to put something like this

load_module modules/ngx_http_js_module.so;

Related