node.js - 无法在Windows 10上设置Electron + Reactjs + sqlite

标签 node.js sqlite electron

我知道在线上有很多关于如何执行此操作的文章。我已经尝试了很多,但从未将其投入工作。
我目前正在尝试将此工作:https://github.com/CosmicEon/Electron-React-Material-SQLite
我的系统:
Windows 10
Node 15.1.0
npm 7.0.11
每次尝试重建sqlite时,都会收到错误消息。在尝试运行时

>npm run rebuild
我得到这个:
> 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
我还安装了一些文章引用的viual Studio构建工具。
我想知道这是否不适用于最新版本的node/npm ...有什么帮助吗?
=======================更新========================== =========
尝试了@Seti的样板,但仍然没有运气。当我尝试运行“ yarn ”时,我得到:
    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.
可能是我的环境有问题....请帮助

最佳答案

这个项目太老了,可能会发生:sqlite3已经是4.2版本,并且在5.something中有续集。最好找到当前十年中的一些启动项目。
也没有 typescript 支持,也没有任何东西。您最好使用https://github.com/electron-react-boilerplate/electron-react-boilerplate,只需将要使用的sequelize和数据库添加到现有的维护样板中。
更新:Sqlite3在 Node 版本15.x(和其他奇数版本)上不起作用,因此请更改为偶数版本(例如14)。

关于node.js - 无法在Windows 10上设置Electron + Reactjs + sqlite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65051766/

相关文章:

java - 快速插入 SQLite Android

node.js - 在浏览器中使用 Electron 代码

webpack - 将 webpack 配置应用到 Electron 主进程

javascript - 如何使用 NodeJs 获取 json 对象中的响应

javascript - 如何在 NodeJS 的 javascript 中一次导入多个变量?

iphone - sqlite3选择查询在IOS6中挂起

ios - 如何将数据预加载到 iOS 的数据库中?

electron - 如何使用 Electron 构建器在 ubuntu 中为 windows 构建 Electron 应用程序

node.js - 使用 Passport-azure-ad 的 OIDCStrategy 的多项政策

javascript - nodeJS util.format 传递一个数组