timotejroiko / sweph

The definitive Swiss Ephemeris bindings for Node.js
Other
93 stars 15 forks source link

Issue in Electron #16

Closed arjunghimire closed 6 months ago

arjunghimire commented 6 months ago

I am creating my own package using this sweph package. I try to install my package in electron project using github link in package json. ie something like this { "dependencies": { "sweph-extend": "git+ssh://git@github.com:arjunghimire/sweph-extend.git" }, }

node -v v20.10.0 npm -v 10.2.3

While running npm install command I got following issue

npm WARN deprecated @types/terser-webpack-plugin@5.2.0: This is a stub types definition. terser-webpack-plugin provides its own type definitions, so you do not need this installed. npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs npm ERR! code 1 npm ERR! path /home/arjun/Projects/Self/merokundaliapp/node_modules/sweph npm ERR! command failed npm ERR! command sh -c node-gyp rebuild && npm run test npm ERR! make: Entering directory '/home/arjun/Projects/Self/merokundaliapp/node_modules/sweph/build' npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swecl.o npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swedate.o npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swehel.o npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swehouse.o npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swejpl.o npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swemmoon.o npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swemplan.o npm ERR! CC(target) Release/obj.target/swisseph/swisseph/sweph.o npm ERR! CC(target) Release/obj.target/swisseph/swisseph/swephlib.o npm ERR! rm -f Release/obj.target/swisseph.a Release/obj.target/swisseph.a.ar-file-list; mkdir -p dirname Release/obj.target/swisseph.a npm ERR! ar crs Release/obj.target/swisseph.a @Release/obj.target/swisseph.a.ar-file-list npm ERR! COPY Release/swisseph.a npm ERR! CXX(target) Release/obj.target/sweph/src/sweph.o npm ERR! make: Leaving directory '/home/arjun/Projects/Self/merokundaliapp/node_modules/sweph/build' npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@9.3.1 npm ERR! gyp info using node@20.10.0 | linux | x64 npm ERR! gyp info find Python using Python version 3.10.12 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/arjun/Projects/Self/merokundaliapp/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/arjun/Projects/Self/merokundaliapp/node_modules/sweph/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/home/arjun/Projects/Self/merokundaliapp/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/home/arjun/.cache/node-gyp/20.10.0/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/arjun/.cache/node-gyp/20.10.0', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/home/arjun/Projects/Self/merokundaliapp/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/home/arjun/.cache/node-gyp/20.10.0/<(target_arch)/node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/arjun/Projects/Self/merokundaliapp/node_modules/sweph', 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! ../swisseph/sweph.c:124:29: warning: missing initializer for field ‘do_interpolate_nut’ of ‘struct swe_data’ [-Wmissing-field-initializers] npm ERR! 124 | }; npm ERR! | ^ npm ERR! In file included from ../swisseph/sweph.c:71: npm ERR! ../swisseph/sweph.h:825:11: note: ‘do_interpolate_nut’ declared here npm ERR! 825 | AS_BOOL do_interpolate_nut; npm ERR! | ^~~~~~ npm ERR! ../swisseph/sweph.c: In function ‘jplplan’: npm ERR! ../swisseph/sweph.c:1988:48: warning: parameter ‘iflag’ set but not used [-Wunused-but-set-parameter] npm ERR! 1988 | static int jplplan(double tjd, int ipli, int32 iflag, AS_BOOL do_save, npm ERR! | ~~^~~~~ npm ERR! ../swisseph/sweph.c: In function ‘search_star_in_list’: npm ERR! ../swisseph/sweph.c:6705:20: warning: comparison of integer expressions of different signedness: ‘long int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare] npm ERR! 6705 | if (sp - sstar != strlen(sstar) - 1) { npm ERR! | ^~ npm ERR! In file included from ../src/sweph.cpp:1: npm ERR! ../src/sweph.h:5:10: fatal error: napi.h: No such file or directory npm ERR! 5 | #include npm ERR! | ^~~~ npm ERR! compilation terminated. npm ERR! make: *** [sweph.target.mk:123: Release/obj.target/sweph/src/sweph.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.onExit (/home/arjun/Projects/Self/merokundaliapp/node_modules/node-gyp/lib/build.js:203:23) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:514:28) npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12) npm ERR! gyp ERR! System Linux 5.15.0-94-generic npm ERR! gyp ERR! command "/home/arjun/.nvm/versions/node/v20.10.0/bin/node" "/home/arjun/Projects/Self/merokundaliapp/node_modules/.bin/node-gyp" "rebuild" npm ERR! gyp ERR! cwd /home/arjun/Projects/Self/merokundaliapp/node_modules/sweph npm ERR! gyp ERR! node -v v20.10.0 npm ERR! gyp ERR! node-gyp -v v9.3.1 npm ERR! gyp ERR! not ok npm ERR! A complete log of this run can be found in: /home/arjun/.npm/_logs/2024-02-12T17_00_36_677Z-debug-0.log

Can anyone please help me to solve this ?

timotejroiko commented 6 months ago

Hello, it seems the installer is not finding napi.h, which should be included in the node-addon-api package.

Try running node -p "require('node-addon-api').include_dir" and see which path it logs, then check the contents of that path.

You can also try manually installing node-addon-api beforehand, or as a preinstall script in your package.json

arjunghimire commented 6 months ago

Great Thanks @timotejroiko. Its working now