winsome
winsome

Reputation: 1

How can I fix 'npm gyp' issue when using 'npm i java' on Ubuntu22.04?



# Error log


[log image]

j@ok:~$ npm i java
npm ERR! code 1
npm ERR! path /home/j/node_modules/java
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
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.10.6 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   '/home/j/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/j/node_modules/java/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/j/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/j/.cache/node-gyp/18.16.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=/home/j/.cache/node-gyp/18.16.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/j/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/home/j/.cache/node-gyp/18.16.1/<(target_ar
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/j/node_modules/java',
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: Call to 'node findJavaHome.js' returned exit status 1 while in binding.gyp. wload binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/home/j/node_modules/node-gyp/lib/con6)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291
npm ERR! gyp ERR! System Linux 5.15.0-76-generic
npm ERR! gyp ERR! command "/usr/bin/node" "/home/j/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/j/node_modules/java
npm ERR! gyp ERR! node -v v18.16.1
npm ERR! gyp ERR! node-gyp -v v9.4.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /home/j/.npm/_logs/2023-07-13T06_53_59og










Code and References




root@ok:~# which python2.7
/usr/local/bin/python2.7
root@ok:~# which python3
/usr/bin/python3



$ sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python2.7 1
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2

sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 3

sudo update-alternatives --set /usr/bin/python python /usr/local/bin/python2.7
$ update-alternatives --config python



$ npm uninstall node-pre-gyp --save
$ npm install @mapbox/node-pre-gyp --save




// check installed global npm modules [https://zetawiki.com/wiki/Npm_%EC%84%A4%EC%B9%98%EB%90%9C_%EC%A0%84%EC%97%AD%EB%AA%A8%EB%93%88_%ED%99%95%EC%9D%B8]


$ npm ls -g --depth=0




// @mapbox/node-pre-gyp [https://yarnpkg.com/package/@mapbox/node-pre-gyp]

$ npm uninstall node-pre-gyp --save
$ npm install @mapbox/node-pre-gyp --save




// sqlite3 install

$ sudo npm i -g sqlite3 --save



Reply on Question



1) Question : What have I tried to resolve the problem?


Answer : In Ubuntu environment, during the development of nodejs I need my environment to use jar files.

reference : [https://www.npmjs.com/package/java]


2)Question : Where are you stuck?

Answer :

When I try to use the command npm i java, There was an error related to node gyp


3) Question : How is installing sqlite related to the problem, or the tag virtualbox?

Answer : After installing Oracle VM Virtualbox in a Windows 10 environment, I'm trying to configure and use the Ubuntu environment.

I want to install 'npm' and use 'npm i java' command That enables the use of java code, which is compiled jar files, during nodejs development.

Upvotes: 0

Views: 214

Answers (0)

Related Questions