WiseLibs / better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.
MIT License
5.44k stars 395 forks source link

Error in Building Electron App #1084

Closed hbole closed 12 months ago

hbole commented 12 months ago

I am using better-sqlite3 v8.1.0 with my electron application I am getting the following error while building the application

I am using node version 16.17.1 Electron version 22.3.27 Need help to resolve this

npm ERR! code 1
npm ERR! path C:\Users\HARSHIT\Desktop\Vyapar\Vyapar_desktop\src\bundle\node_modules\better-sqlite3
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c C:\Users\HARSHIT\AppData\Local\Temp\install-0579c53d.cmd
npm ERR! Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
npm ERR!   extract_sqlite3
npm ERR!   sqlite3.c
npm ERR!   win_delay_load_hook.cc
npm ERR!   sqlite3.vcxproj -> C:\Users\HARSHIT\Desktop\Vyapar\Vyapar_desktop\src\bundle\node_modules\better-sqlite3\build\Release\\sqlite3.lib
npm ERR!   better_sqlite3.cpp
npm ERR! c:\users\harshit\desktop\vyapar\vyapar_desktop\src\bundle\node_modules\better-sqlite3\build\src\objects\database.lzz(367): warning C4309: 'static_cast': truncation of constant value [C:\Users\HARSHIT\Desktop\Vyapar\Vyapar_desktop\src\bundle\node_modules\better-sqlite3\build\better_sqlite3.vcxproj]
npm ERR! c:\users\harshit\desktop\vyapar\vyapar_desktop\src\bundle\node_modules\better-sqlite3\build\src\objects\database.lzz(129): error C2660: 'node::AtExit': function does not take 1 arguments [C:\Users\HARSHIT\Desktop\Vyapar\Vyapar_desktop\src\bundle\node_modules\better-sqlite3\build\better_sqlite3.vcxproj]
npm ERR!   c:\users\harshit\appdata\local\node-gyp\cache\16.17.1\include\node\node.h(951): note: see declaration of 'node::AtExit'
npm ERR! c:\users\harshit\desktop\vyapar\vyapar_desktop\src\bundle\node_modules\better-sqlite3\build\src\util\binder.lzz(36): warning C4996: 'v8::Object::CreationContext': Use MaybeLocal<Context> GetCreationContext() [C:\Users\HARSHIT\Desktop\Vyapar\Vyapar_desktop\src\bundle\node_modules\better-sqlite3\build\better_sqlite3.vcxproj]
npm ERR!   c:\users\harshit\appdata\local\node-gyp\cache\16.17.1\include\node\v8.h(4316): note: see declaration of 'v8::Object::CreationContext'
npm ERR!   test_extension.c
npm ERR!   win_delay_load_hook.cc
npm ERR!   Generating code
npm ERR!   All 2 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
npm ERR!   Finished generating code
npm ERR!   test_extension.vcxproj -> C:\Users\HARSHIT\Desktop\Vyapar\Vyapar_desktop\src\bundle\node_modules\better-sqlite3\build\Release\\test_extension.node        
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.4.0
npm ERR! gyp info using node@16.17.1 | win32 | x64
npm ERR! gyp info find Python using Python version 3.7.9 found at "C:\Users\HARSHIT\AppData\Local\Programs\Python\Python37\python.exe"
npm ERR! gyp info find VS using VS2017 (15.9.34031.82) found at:
npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Users\HARSHIT\AppData\Local\Programs\Python\Python37\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\Users\\HARSHIT\\Desktop\\Vyapar\\Vyapar_desktop\\src\\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\\HARSHIT\\Desktop\\Vyapar\\Vyapar_desktop\\src\\bundle\\node_modules\\better-sqlite3\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\HARSHIT\\Desktop\\Vyapar\\Vyapar_desktop\\src\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\HARSHIT\\AppData\\Local\\node-gyp\\Cache\\16.17.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=C:\\Users\\HARSHIT\\AppData\\Local\\node-gyp\\Cache\\16.17.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\HARSHIT\\Desktop\\Vyapar\\Vyapar_desktop\\src\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\HARSHIT\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.17.1\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\HARSHIT\\Desktop\\Vyapar\\Vyapar_desktop\\src\\bundle\\node_modules\\better-sqlite3',
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\\HARSHIT\\Desktop\\Vyapar\\Vyapar_desktop\\src\\bundle\\node_modules\\better-sqlite3\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\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\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\Users\HARSHIT\Desktop\Vyapar\Vyapar_desktop\src\node_modules\node-gyp\lib\build.js:203: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:291:12)
npm ERR! gyp ERR! System Windows_NT 10.0.22621
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\HARSHIT\\Desktop\\Vyapar\\Vyapar_desktop\\src\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\HARSHIT\Desktop\Vyapar\Vyapar_desktop\src\bundle\node_modules\better-sqlite3
npm ERR! gyp ERR! node -v v16.17.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:
npm ERR!     C:\Users\HARSHIT\AppData\Local\npm-cache\_logs\2023-10-11T09_23_07_425Z-debug-0.log
Prinzhorn commented 12 months ago

I am using better-sqlite3 v8.1.0

Before opening issues I recommend to always try with the latest version (v8.7.0 or v9.0.0). This is true for any library or software ever.

I am using node version 16.17.1

Has reached EOL

Electron version 22.3.27

Has reached EOL

hbole commented 12 months ago

I tried with the latest version of better-sqlite3 v8.7.0 still facing the same issue @Prinzhorn

neoxpert commented 12 months ago

As there are prebuilt binaries of better-sqlite3 v8.7.0 for Node 16 (ABI version 93) and for Electron 22 (ABI version 110) available, this seems to be an issue related to your local setup if those are not properly resolved.

How does the install process / package.json of this app look like? Does the issue also occur using this minimal example (tested on Win 10 x64 with NodeJS 16.20.2):

{
  "name": "sample",
  "version": "1.0.0",
  "scripts": {
    "postinstall": "electron-builder install-app-deps"
  },
  "devDependencies": {
    "electron": "22.3.27",
    "electron-builder": "24.6.4"
  },
  "dependencies": {
    "better-sqlite3": "8.7.0"
  }
}
hbole commented 12 months ago

Sorry @Prinzhorn @neoxpert

It was due to wrong webpack configuration. It is working fine now. Closing this issue.

Just one request, the error messages can be more definitive.