naturalatlas / node-gdal

Node.js bindings for GDAL (Geospatial Data Abstraction Library)
http://naturalatlas.github.io/node-gdal/classes/gdal.html
Apache License 2.0
567 stars 124 forks source link

Using node-gdal in electron #281

Open oliTF opened 3 years ago

oliTF commented 3 years ago

System

node: 14.16.1 system: win10 electron: 12.0.4 node-gdal: 0.10.1

Problem

After installing and requiring with var gdal = require("gdal");, a cannot find module error appears:

Uncaught Error: Cannot find module '...\electron-quick-start\node_modules\gdal\lib\binding\electron-v12.0-win32-x64\gdal.node'
Require stack:
- ...\electron-quick-start\node_modules\gdal\lib\gdal.js
- ...\electron-quick-start\index.html
    at Module._resolveFilename (internal/modules/cjs/loader.js:887)
    at Function.o._resolveFilename (electron/js2c/renderer_init.js:33)
    at Module._load (internal/modules/cjs/loader.js:732)
    at Function.f._load (electron/js2c/asar_bundle.js:5)
    at Function.o._load (electron/js2c/renderer_init.js:33)
    at Module.require (internal/modules/cjs/loader.js:959)
    at require (internal/modules/cjs/helpers.js:88)
    at Object.<anonymous> (...\electron-quick-start\node_modules\gdal\lib\gdal.js:12)
    at Object.<anonymous> (....\electron-quick-start\node_modules\gdal\lib\gdal.js:701)
    at Module._compile (internal/modules/cjs/loader.js:1078)

After installation, the gdal.node is found in followin path ...\electron-quick-start\node_modules\gdal\lib\binding\node-v83-win32-x64.

I followed this issue #219 with using node-gdal 0.10.1, but I could not resolve the issue. Does it have to do something with https://github.com/mapbox/node-pre-gyp? When installing, the following warning appears:

node_gdal_install_electron

How can this problem be resolved?

hail-kang commented 3 years ago

gdal is a native module. See the link below. https://www.electronjs.org/docs/tutorial/using-native-node-modules

However, even if you proceed as described in the link, problems arise. https://github.com/electron/electron-rebuild/issues/734

VadimCiv commented 3 years ago

Can't compile !!! I can't compiling goal-node in my electron 11 app when I use rpm install rebuilding native dependencies dependencies=gdal@0.11.0 platform=win32 arch=x64 windows 10 nodes 16 electron 11 electron-builder 22

Please Help!

-napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v11.5' (1)
    npm ERR! node-pre-gyp info it worked if it ends with ok
    npm ERR! node-pre-gyp info using node-pre-gyp@1.0.6
    npm ERR! node-pre-gyp info using node@16.12.0 | win32 | x64
    npm ERR! node-pre-gyp http GET https://github.com/naturalatlas/node-gdal/releases/download/0.11.0/electron-v11.5-win32-x64-unknown.tar.gz
    npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/naturalatlas/node-gdal/releases/download/0.11.0/electron-v11.5-win32-x64-unknown.tar.gz
    npm ERR! node-pre-gyp WARN Pre-built binaries not installable for gdal@0.11.0 and electron@11.5.0 (electron-v11.5 ABI, unknown) (falling back to source compile with node-gyp)
    npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/naturalatlas/node-gdal/releases/download/0.11.0/electron-v11.5-win32-x64-unknown.tar.gz
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@8.2.0
    npm ERR! gyp info using node@16.12.0 | win32 | x64
    npm ERR! gyp info ok
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@8.2.0
    npm ERR! gyp info using node@16.12.0 | win32 | x64
    npm ERR! gyp info find Python using Python version 3.9.8 found at "C:\Users\user\AppData\Local\Programs\Python\Python39\python.exe"
    npm ERR! gyp info find VS using VS2017 (15.9.28307.1745) found at:
    npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community"
    npm ERR! gyp info find VS run with --verbose for detailed information
    npm ERR! gyp info spawn C:\Users\user\AppData\Local\Programs\Python\Python39\python.exe
    npm ERR! gyp info spawn args [
    npm ERR! gyp info spawn args   'C:\\Program Files\\nodejs\\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   'msvs',
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   'C:\\Users\\user\\git\\planner\\node_modules\\gdal\\build\\config.gypi', 
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   'C:\\Users\\user\\git\\planner\\node_modules\\gdal\\common.gypi',        
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   'C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi', 
    npm ERR! gyp info spawn args   '-I',
    npm ERR! gyp info spawn args   'C:\\Users\\user\\.electron-gyp\\11.5.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=C:\\Users\\user\\.electron-gyp\\11.5.0',
    npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp',
    npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\user\\\\.electron-gyp\\\\11.5.0\\\\<(target_arch)\\\\node.lib',
    npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\user\\git\\planner\\node_modules\\gdal',   
    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   'C:\\Users\\user\\git\\planner\\node_modules\\gdal\\build',
    npm ERR! gyp info spawn args   '-Goutput_dir=.'
    npm ERR! gyp info spawn args ]
    npm ERR! gyp info ok
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@8.2.0
    npm ERR! gyp info using node@16.12.0 | win32 | x64
    npm ERR! gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe 
    npm ERR! gyp info spawn args [
    npm ERR! gyp info spawn args   'build/binding.sln',
    npm ERR! gyp info spawn args   '/clp:Verbosity=minimal',
    npm ERR! gyp info spawn args   '/nologo',
    npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
    npm ERR! gyp info spawn args ]
    npm ERR! gyp ERR! build error
    npm ERR! gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
    npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
    npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
    npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
    npm ERR! gyp ERR! System Windows_NT 10.0.19042
    npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\user\\git\\planner\\node_modules\\gdal\\lib\\binding\\gdal.node" "--module_name=gdal" "--module_path=C:\\Users\\user\\git\\planner\\node_modules\\gdal\\lib\\binding" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=electron-v11.5"
    npm ERR! gyp ERR! cwd C:\Users\user\git\planner\node_modules\gdal
    npm ERR! gyp ERR! node -v v16.12.0
    npm ERR! gyp ERR! node-gyp -v v8.2.0
    npm ERR! gyp ERR! not ok
    npm ERR! node-pre-gyp ERR! build error
    npm ERR! node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\user\git\planner\node_modules\gdal\lib\binding\gdal.node --module_name=gdal --module_path=C:\Users\user\git\planner\node_modules\gdal\lib\binding --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v11.5' (1)
    npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\user\git\planner\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:89:23)
    npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
    npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
    npm ERR! node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)    
    npm ERR! node-pre-gyp ERR! System Windows_NT 10.0.19042
    npm ERR! node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user\\git\\planner\\node_modules\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
    npm ERR! node-pre-gyp ERR! cwd C:\Users\user\git\planner\node_modules\gdal
    npm ERR! node-pre-gyp ERR! node -v v16.12.0
    npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.6
    npm ERR! node-pre-gyp ERR! not ok
acesgrandpa commented 1 year ago

Maybe you can try gdal3. js. I haven't thoroughly tested its functionality yet, but at least it can be installed。

acesgrandpa commented 1 year ago

https://github.com/bugra9/gdal3.js