Warm tip: This article is reproduced from serverfault.com, please click

Can't setup Electron + Reactjs + sqlite on windows 10

发布于 2020-11-28 16:16:59

I know there's quite a few articles online on how to do this. I've tried a bunch of them and was never able to put it to work. I'm currently trying to put this to work: https://github.com/CosmicEon/Electron-React-Material-SQLite. My System: Windows 10 node 15.1.0 npm 7.0.11

Every time I try to rebuild sqlite I get errors. while trying to run

>npm run rebuild

I'm getting this:

> material-dashboard-react@1.0.0 rebuild
> electron-rebuild -f -w sqlite3

× Rebuild Failed

An unhandled error occurred inside electron-rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@15.1.0 | win32 | x64
gyp http GET https://atom.io/download/electron/v1.8.2/iojs-v1.8.2.tar.gz
gyp http 200 https://atom.io/download/electron/v1.8.2/iojs-v1.8.2.tar.gz
gyp http GET https://atom.io/download/electron/v1.8.2/SHASUMS256.txt
gyp http GET https://atom.io/download/electron/v1.8.2/win-x64/iojs.lib
gyp http GET https://atom.io/download/electron/v1.8.2/win-x86/iojs.lib
gyp http 200 https://atom.io/download/electron/v1.8.2/SHASUMS256.txt
gyp http 200 https://atom.io/download/electron/v1.8.2/win-x64/iojs.lib
gyp http 200 https://atom.io/download/electron/v1.8.2/win-x86/iojs.lib
gyp info spawn C:\Python27\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\workspace\\eTimer\\e-timer-2\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=2015',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\workspace\\eTimer\\e-timer-2\\node_modules\\fsevents\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\workspace\\eTimer\\e-timer-2\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\USER\\.electron-gyp\\.node-gyp\\iojs-1.8.2\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\USER\\.electron-gyp\\.node-gyp\\iojs-1.8.2',
gyp info spawn args   '-Dnode_gyp_dir=C:\\workspace\\eTimer\\e-timer-2\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\Users\\USER\\.electron-gyp\\.node-gyp\\iojs-1.8.2\\<(target_arch)\\iojs.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\workspace\\eTimer\\e-timer-2\\node_modules\\fsevents',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\workspace\\eTimer\\e-timer-2\\node_modules\\fsevents\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
Traceback (most recent call last):
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 538, in main
    return gyp_main(args)
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 523, in gyp_main
    generator.GenerateOutput(flat_list, targets, data, params)
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 2019, in GenerateOutput
    sln_projects, project_objects, flat=msvs_version.FlatSolution())
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1778, in _GatherSolutionFolders
    return _DictsToFolders('', root, flat)
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1731, in _DictsToFolders
    for folder, contents in bucket.iteritems():
AttributeError: 'MSVSProject' object has no attribute 'iteritems'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\lib\configure.js:336:16)
gyp ERR! stack     at ChildProcess.emit (node:events:327:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:277:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\app\\nodejs\\node.exe" "C:\\workspace\\eTimer\\e-timer-2\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=1.8.2" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=fse" "--module_path=C:\\workspace\\eTimer\\e-timer-2\\node_modules\\fsevents\\lib\\binding\\Release\\electron-v1.8-win32-x64" "--remote_path=./v1.1.2/" "--package_name=fse-v1.1.2-electron-v1.8-win32-x64.tar.gz" "--host=https://fsevents-binaries.s3-us-west-2.amazonaws.com"
gyp ERR! cwd C:\workspace\eTimer\e-timer-2\node_modules\fsevents
gyp ERR! node -v v15.1.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

Failed with exit code: 1

Error: gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@15.1.0 | win32 | x64
gyp http GET https://atom.io/download/electron/v1.8.2/iojs-v1.8.2.tar.gz
gyp http 200 https://atom.io/download/electron/v1.8.2/iojs-v1.8.2.tar.gz
gyp http GET https://atom.io/download/electron/v1.8.2/SHASUMS256.txt
gyp http GET https://atom.io/download/electron/v1.8.2/win-x64/iojs.lib
gyp http GET https://atom.io/download/electron/v1.8.2/win-x86/iojs.lib
gyp http 200 https://atom.io/download/electron/v1.8.2/SHASUMS256.txt
gyp http 200 https://atom.io/download/electron/v1.8.2/win-x64/iojs.lib
gyp http 200 https://atom.io/download/electron/v1.8.2/win-x86/iojs.lib
gyp info spawn C:\Python27\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\workspace\\eTimer\\e-timer-2\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=2015',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\workspace\\eTimer\\e-timer-2\\node_modules\\fsevents\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\workspace\\eTimer\\e-timer-2\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\USER\\.electron-gyp\\.node-gyp\\iojs-1.8.2\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\USER\\.electron-gyp\\.node-gyp\\iojs-1.8.2',
gyp info spawn args   '-Dnode_gyp_dir=C:\\workspace\\eTimer\\e-timer-2\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\Users\\USER\\.electron-gyp\\.node-gyp\\iojs-1.8.2\\<(target_arch)\\iojs.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\workspace\\eTimer\\e-timer-2\\node_modules\\fsevents',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\workspace\\eTimer\\e-timer-2\\node_modules\\fsevents\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
Traceback (most recent call last):
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 538, in main
    return gyp_main(args)
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 523, in gyp_main
    generator.GenerateOutput(flat_list, targets, data, params)
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 2019, in GenerateOutput
    sln_projects, project_objects, flat=msvs_version.FlatSolution())
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1778, in _GatherSolutionFolders
    return _DictsToFolders('', root, flat)
  File "C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1731, in _DictsToFolders
    for folder, contents in bucket.iteritems():
AttributeError: 'MSVSProject' object has no attribute 'iteritems'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\workspace\eTimer\e-timer-2\node_modules\node-gyp\lib\configure.js:336:16)
gyp ERR! stack     at ChildProcess.emit (node:events:327:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:277:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\app\\nodejs\\node.exe" "C:\\workspace\\eTimer\\e-timer-2\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=1.8.2" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=fse" "--module_path=C:\\workspace\\eTimer\\e-timer-2\\node_modules\\fsevents\\lib\\binding\\Release\\electron-v1.8-win32-x64" "--remote_path=./v1.1.2/" "--package_name=fse-v1.1.2-electron-v1.8-win32-x64.tar.gz" "--host=https://fsevents-binaries.s3-us-west-2.amazonaws.com"
gyp ERR! cwd C:\workspace\eTimer\e-timer-2\node_modules\fsevents
gyp ERR! node -v v15.1.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

Failed with exit code: 1
    at SafeSubscriber._error (C:\workspace\eTimer\e-timer-2\node_modules\spawn-rx\lib\src\index.js:277:84)
    at SafeSubscriber.__tryOrUnsub (C:\workspace\eTimer\e-timer-2\node_modules\rxjs\Subscriber.js:239:16)
    at SafeSubscriber.error (C:\workspace\eTimer\e-timer-2\node_modules\rxjs\Subscriber.js:198:26)
    at Subscriber._error (C:\workspace\eTimer\e-timer-2\node_modules\rxjs\Subscriber.js:129:26)
    at Subscriber.error (C:\workspace\eTimer\e-timer-2\node_modules\rxjs\Subscriber.js:103:18)
    at MapSubscriber.Subscriber._error (C:\workspace\eTimer\e-timer-2\node_modules\rxjs\Subscriber.js:129:26)
    at MapSubscriber.Subscriber.error (C:\workspace\eTimer\e-timer-2\node_modules\rxjs\Subscriber.js:103:18)
    at SafeSubscriber._next (C:\workspace\eTimer\e-timer-2\node_modules\spawn-rx\lib\src\index.js:251:65)
    at SafeSubscriber.__tryOrSetError (C:\workspace\eTimer\e-timer-2\node_modules\rxjs\Subscriber.js:248:16)
    at SafeSubscriber.next (C:\workspace\eTimer\e-timer-2\node_modules\rxjs\Subscriber.js:188:27)
npm ERR! code 4294967295
npm ERR! path C:\workspace\eTimer\e-timer-2
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "electron-rebuild -f -w sqlite3"

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\USER\AppData\Local\npm-cache\_logs\2020-11-28T15_57_54_619Z-debug.logenter code here

I also installed the viual studio build tools as some articles refer..

I'm wondering if this simply doesn't work with node/npm latest versions... any help?

======================= Update ===================================

Tried the boilerplate @Seti mentioned, but still no luck. When I try to run "yarn" i get:

    PS C:\workspace\etimer\e-timer-3\e-timer> yarn                                                                          yarn install v1.22.5
[1/4] Resolving packages...
success Already up-to-date.
$ node -r @babel/register .erb/scripts/CheckNativeDep.js && electron-builder install-app-deps && yarn cross-env NODE_ENV=development webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.babel.js && opencollective-postinstall && yarn-deduplicate yarn.lock
Native dependencies could not be checked
  • electron-builder  version=22.9.1
  • loaded configuration  file=package.json ("build" field)
  • installing production dependencies  platform=win32 arch=x64 appDir=C:\workspace\etimer\e-timer-3\e-timer\src
yarn run v1.22.5
$ C:\workspace\etimer\e-timer-3\e-timer\node_modules\.bin\cross-env NODE_ENV=development webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.babel.js
[webpack-cli] TypeError: The 'compilation' argument must be an instance of Compilation
    at Function.getCompilationHooks (C:\workspace\etimer\e-timer-3\e-timer\node_modules\webpack\lib\NormalModule.js:171:10)
    at C:\workspace\etimer\e-timer-3\e-timer\node_modules\webpack\lib\LoaderOptionsPlugin.js:43:17
    at Hook.eval (eval at create (C:\workspace\eTimer\e-timer-3\e-timer\node_modules\tapable\lib\HookCodeFactory.js:19:10), <anonymous>:104:1)
    at Hook.CALL_DELEGATE [as _call] (C:\workspace\eTimer\e-timer-3\e-timer\node_modules\tapable\lib\Hook.js:14:14)
    at Compiler.newCompilation (C:\workspace\eTimer\e-timer-3\e-timer\node_modules\webpack\lib\Compiler.js:943:26)
    at C:\workspace\eTimer\e-timer-3\e-timer\node_modules\webpack\lib\Compiler.js:984:29
    at Hook.eval [as callAsync] (eval at create (C:\workspace\eTimer\e-timer-3\e-timer\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\workspace\eTimer\e-timer-3\e-timer\node_modules\tapable\lib\Hook.js:18:14)
    at Compiler.compile (C:\workspace\eTimer\e-timer-3\e-timer\node_modules\webpack\lib\Compiler.js:979:28)
    at C:\workspace\eTimer\e-timer-3\e-timer\node_modules\webpack\lib\Compiler.js:470:12
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

maybe something's wrong with my environment.... please help

Questioner
cattox
Viewed
0
Seti 2021-02-11 22:08:51

This project is so old that might happen: sqlite3 is in 4.2 version already, and sequelize in 5.something. Better find some starting project that is in current decade.

There is also no typescript support nor anything. You better use https://github.com/electron-react-boilerplate/electron-react-boilerplate and just add sequelize and database you want to use to existing maintained boilerplate.

UPDATE: Sqlite3 do not work on node version 15.x (and other odd version) so please change to even version (14 for example).