unit icon indicating copy to clipboard operation
unit copied to clipboard

unable to install unit-http

Open allwin-winfred opened this issue 1 year ago • 1 comments

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 [email protected] npm ERR! gyp info using [email protected] | 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

allwin-winfred avatar May 12 '24 10:05 allwin-winfred

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?

ac000 avatar May 14 '24 00:05 ac000

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

allwin-winfred avatar May 14 '24 05:05 allwin-winfred

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

allwin-winfred avatar May 14 '24 12:05 allwin-winfred

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.

ac000 avatar May 14 '24 14:05 ac000

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

dbit-xia avatar May 15 '24 09:05 dbit-xia

@dbit-xia here is my unitd version

 unitd --version
unit version: 1.33.0
configured as ./configure

allwin-winfred avatar May 15 '24 09:05 allwin-winfred

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

dbit-xia avatar May 15 '24 09:05 dbit-xia

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

allwin-winfred avatar May 15 '24 09:05 allwin-winfred

@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 [email protected]
npm ERR! gyp info using [email protected] | 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 avatar May 15 '24 10:05 allwin-winfred

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

allwin-winfred avatar May 15 '24 12:05 allwin-winfred

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 <nxt_unit.h> npm ERR! | ^~~~~~~~~~~~

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

ac000 avatar May 15 '24 14:05 ac000

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.

thresheek avatar May 15 '24 17:05 thresheek

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

allwin-winfred avatar May 16 '24 05:05 allwin-winfred