Unit: Unable to install unit-http

Created on 8 Jun 2019  路  17Comments  路  Source: nginx/unit

Going through the configuration and Installation guide here:
https://unit.nginx.org/installation/#node-js-package

When it comes to installing unit-http, It terminates with:

fatal error: nxt_napi.h: No such file or directory 9 | #include "nxt_napi.h"

Node version: 12.4.0
npm version: 6.9.0
Also have node-gyp installed.

Going through the file directories: /usr/local/lib/node_modules there is no unit-http folder, but there is an http and a seperate unit folder, Has there been a crossover due to updates or am I missing it entirely?

All 17 comments

Hi,

Most probably, this step went missing:

First, install the unit-dev/unit-devel package; it鈥檚 used by unit-http.

Hey @artemkonev - I did install the devel-package, and again it was throwing that error, I shall check later today to see if there has been an error in the installation and get back to you.

Hi,

I have reproduced the issue, we're looking into that as well.

Hey

Any update on this at all?

Was it a crossover with the installation - Perhaps a file directory path doesn't line up right for installation or after?

Hello! I'm having the same problem, trying to install on debian 9 with the same node version (12.4.0), unit-dev installed, trying to install the latest/default version (1.9.0), and node-gyp can't find nxt_napi.h, either with yarn or npm.

The file's not present in the unit-http package or build folder, or as far as I can tell in the unit-dev source package (neither dpkg -L unit-dev nor dpkg -c /var/cache/apt/archives/unit-dev_1.9.0-1~stretch_amd64.deb show it). Trying to install previous versions of the npm package gives #error "libunit version mismatch".

I made a gist of the full output.

Any thoughts would be very welcome, thanks!

trying to install the latest/default version (1.9.0), and node-gyp can't find nxt_napi.h, either with yarn or npm

It's missing in the package.json file. The patch below should fix the issue:

diff --git a/src/nodejs/unit-http/package.json b/src/nodejs/unit-http/package.json
--- a/src/nodejs/unit-http/package.json
+++ b/src/nodejs/unit-http/package.json
@@ -10,6 +10,7 @@
         "unit.cpp",
         "http.js",
         "http_server.js",
+        "nxt_napi.h",
         "package.json",
         "socket.js",
         "binding.gyp",

Thanks Valentin! Away from computer at the mo but will try later. Will apply the patch to the downloaded version and try again. Will the package be updated in npm to reflect it?

Hi again, not sure where to do this, I applied it to the package.json in the node_modules/unit-http/package.json and then ran yarn add unit-http (and just plain yarn) but it must be regenerating the file because it fails with the same error and then looking afterwards at the package.json the nxt_napi.h line isn't there any more. Do you mean this should be applied to the unit sources? I've installed both unit and unit-dev via apt on debian, so I don't know where to add this. Also the file nxt_napi.h file doesn't exist anywhere on my disk, so unless the patch should be applied in the source of something else which builds either unit or unit-http then I don't understand how it will fix the missing file...

How do I apply this patch on a .deb-installed unit installation?

Thanks!

@igorclark
Now even if you try it f from unit sources you will get an error, it is missing the version.h :)

@igorclark The unit-http package is generated from sources and then uploaded to npm repository. We are going to update the npm package on Monday. Till then you can apply the patch to Unit sources and generate the package on your own. Here's how I've just done it on a Debian 9 system:

% hg clone https://hg.nginx.org/unit
% cd unit
% hg up -r 1.9.0
% patch -p1 
diff --git a/src/nodejs/unit-http/package.json b/src/nodejs/unit-http/package.json
--- a/src/nodejs/unit-http/package.json
+++ b/src/nodejs/unit-http/package.json
@@ -10,6 +10,7 @@
         "unit.cpp",
         "http.js",
         "http_server.js",
+        "nxt_napi.h",
         "package.json",
         "socket.js",
         "binding.gyp",
% ./configure
% ./configure nodejs
% sudo make node-install

@igorclark
Now even if you try it f from unit sources you will get an error, it is missing the version.h :)

In order to create a Node.js module from Unit sources, you have to ./configure the sources and then make the module. See the documentation here: https://unit.nginx.org/installation/#source-code or the instruction above.

Hi @VBart, thanks very much, I built it using your patch and instructions and it works great! Excited to run node apps using unit. Looking forward to the npm update. Thank you! 馃榾

Hi again @VBart, sorry to bug you, do you think it will be possible to update the npm package today, or when it might be possible, if not today? I'm working on an automated VM builder of my own and it'd be great to be able to pull in unit-http automatically with yarn. Thanks 馃憤

Hi again @VBart, sorry to bug you, do you think it will be possible to update the npm package today

I hope so. @defanator is working on it.

@igorclark Fixed npm package has been uploaded as unit-http 1.9.2.
https://www.npmjs.com/package/unit-http/v/1.9.2

Wonderful, thanks @VBart & @defanator! Probably won鈥檛 be get to it til the morning now but will report back then. Thank you 馃檹馃徏

Seems to work perfectly. Going to try it in earnest. Thanks again!

Was this page helpful?
0 / 5 - 0 ratings