nginx / unit

NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
https://unit.nginx.org
Apache License 2.0
5.25k stars 321 forks source link

unable to install unit-http #1260

Closed allwin-winfred closed 1 month ago

allwin-winfred commented 1 month ago

hi team, I'm trying npm i uni-http and npm i -g unit-http getting an error,

npm ERR! command sh -c -- node-gyp configure build npm ERR! make: Entering directory '/home/azureuser/node_modules/unit-http/build' npm ERR! CXX(target) Release/obj.target/unit-http/unit.o npm ERR! make: Leaving directory '/home/azureuser/node_modules/unit-http/build' npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@9.1.0 npm ERR! gyp info using node@16.20.2 | linux | x64 npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3" npm ERR! gyp info spawn /usr/bin/python3 npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py', npm ERR! gyp info spawn args 'binding.gyp', npm ERR! gyp info spawn args '-f', npm ERR! gyp info spawn args 'make', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/home/azureuser/node_modules/unit-http/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/home/azureuser/.cache/node-gyp/16.20.2/include/node/common.gypi', npm ERR! gyp info spawn args '-Dlibrary=shared_library', npm ERR! gyp info spawn args '-Dvisibility=default', npm ERR! gyp info spawn args '-Dnode_root_dir=/home/azureuser/.cache/node-gyp/16.20.2', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/home/azureuser/.cache/node-gyp/16.20.2/<(target_arch)/node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/azureuser/node_modules/unit-http', npm ERR! gyp info spawn args '-Dnode_engine=v8', npm ERR! gyp info spawn args '--depth=.', npm ERR! gyp info spawn args '--no-parallel', npm ERR! gyp info spawn args '--generator-output', npm ERR! gyp info spawn args 'build', npm ERR! gyp info spawn args '-Goutput_dir=.' npm ERR! gyp info spawn args ] npm ERR! gyp info spawn make npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] npm ERR! In file included from ../unit.h:9, npm ERR! from ../unit.cpp:6: npm ERR! ../nxt_napi.h:20:2: error: #error "libunit version mismatch." npm ERR! 20 | #error "libunit version mismatch." npm ERR! | ^~~~~ npm ERR! make: *** [unit-http.target.mk:110: Release/obj.target/unit-http/unit.o] Error 1 npm ERR! gyp ERR! build error npm ERR! gyp ERR! stack Error:makefailed with exit code: 2 npm ERR! gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:201:23) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28) npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12) npm ERR! gyp ERR! System Linux 5.15.0-1063-azure npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build" npm ERR! gyp ERR! cwd /home/azureuser/node_modules/unit-http npm ERR! gyp ERR! node -v v16.20.2 npm ERR! gyp ERR! node-gyp -v v9.1.0 npm ERR! gyp ERR! not ok

ac000 commented 1 month ago

Given

npm ERR! gyp info spawn make npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] npm ERR! In file included from ../unit.h:9, npm ERR! from ../unit.cpp:6: npm ERR! ../nxt_napi.h:20:2: error: #error "libunit version mismatch." npm ERR! 20 | #error "libunit version mismatch." npm ERR! | ^~~~~ npm ERR! make: *** [unit-http.target.mk:110: Release/obj.target/unit-http/unit.o] Error 1 npm ERR! gyp ERR! build error

It looks like the version of the nodejs module you're trying to build (or at least install unit-http against) differs from the version of Unit you're building against.

What OS are you using?

Are you using any Unit packages or is it all built from source?

allwin-winfred commented 1 month ago

I'm using Ubuntu-20.04LTS and I'm installing unit from https://unit.nginx.org/installation/#ubuntu-2004

allwin-winfred commented 1 month ago

my environment,

NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
ac000 commented 1 month ago

Ah, right, we don't provide nodejs language module packages for $reasons.

The docs suggest that you should run npm install -g --unsafe-perm unit-http as root, Caveat Emptor, alternatively you can build as yourself from the Unit sources.

Currently it looks like you are kind of doing a mixture of the two, you have Unit installed system-wide but it looks like the npm command is finding some local install which doesn't match the unit-http version you're trying to build/install.

dbit-xia commented 1 month ago

check version of unitd, don't use 1.32.1, because there is no 1.32.1 in npmjs If it is not the latest version, you can try npm install --unsafe-perm unit-http@version

allwin-winfred commented 1 month ago

@dbit-xia here is my unitd version

 unitd --version
unit version: 1.33.0
configured as ./configure
dbit-xia commented 1 month ago

Wow, your version number is too new, but npmjs only has packages smaller than 1.32.0, why not try 1.32.0 https://www.npmjs.com/package/unit-http?activeTab=versions

allwin-winfred commented 1 month ago

Got it! I will try setting up a new virtual machine and attempt to install version 1.32.1 of the unit.

allwin-winfred commented 1 month ago

@dbit-xia @ac000 , here I installed unit 1.32.1 and I executed the npm i -g unit-http, I got the error,

npm ERR! code 1
npm ERR! path /root/.nvm/versions/node/v20.13.1/lib/node_modules/unit-http
npm ERR! command failed
npm ERR! command sh -c node-gyp configure build
npm ERR! make: Entering directory '/root/.nvm/versions/node/v20.13.1/lib/node_modules/unit-http/build'
npm ERR!   CXX(target) Release/obj.target/unit-http/unit.o
npm ERR! make: Leaving directory '/root/.nvm/versions/node/v20.13.1/lib/node_modules/unit-http/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.1.0
npm ERR! gyp info using node@20.13.1 | linux | x64
npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/root/.nvm/versions/node/v20.13.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/.nvm/versions/node/v20.13.1/lib/node_modules/unit-http/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/.nvm/versions/node/v20.13.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/.cache/node-gyp/20.13.1/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/20.13.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/root/.nvm/versions/node/v20.13.1/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/20.13.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/root/.nvm/versions/node/v20.13.1/lib/node_modules/unit-http',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../unit.h:9,
npm ERR!                  from ../unit.cpp:6:
npm ERR! ../nxt_napi.h:17:10: fatal error: nxt_unit.h: No such file or directory
npm ERR!    17 | #include <nxt_unit.h>
npm ERR!       |          ^~~~~~~~~~~~
npm ERR! compilation terminated.
npm ERR! make: *** [unit-http.target.mk:105: Release/obj.target/unit-http/unit.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (/root/.nvm/versions/node/v20.13.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Linux 5.15.0-1064-azure
npm ERR! gyp ERR! command "/root/.nvm/versions/node/v20.13.1/bin/node" "/root/.nvm/versions/node/v20.13.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
npm ERR! gyp ERR! cwd /root/.nvm/versions/node/v20.13.1/lib/node_modules/unit-http
npm ERR! gyp ERR! node -v v20.13.1
npm ERR! gyp ERR! node-gyp -v v10.1.0
npm ERR! gyp ERR! not ok
allwin-winfred commented 1 month ago

@dbit-xia @ac000 I tried various methods, but I couldn't install unit-http on my server.

ac000 commented 1 month ago

On Wed, 15 May 2024 03:36:52 -0700 Allwin Winfred J @.***> wrote:

npm ERR! In file included from ../unit.h:9, npm ERR! from ../unit.cpp:6: npm ERR! ../nxt_napi.h:17:10: fatal error: nxt_unit.h: No such file or directory npm ERR! 17 | #include npm ERR! | ^~~~

Did you install Unit via a package? and did you install the unit-devel / unit-dev package?

thresheek commented 1 month ago

FYI: I've updated the unit-http version as published on npmjs, seems like it was forgotten during the release time. You still need a corresponding unit-devel/unit-dev package installed if you did it via package manager.

allwin-winfred commented 1 month ago

hey @thresheek @ac000 @dbit-xia, After I installed unit-dev package is installed, thank you so much team🎉