【问题标题】:Can't setup Electron + Reactjs + sqlite on windows 10无法在 Windows 10 上设置 Electron + Reactjs + sqlite
【发布时间】:2021-03-11 02:06:54
【问题描述】:

我知道网上有很多关于如何做到这一点的文章。我已经尝试了很多,但始终无法将其投入使用。 我目前正在尝试使用它:https://github.com/CosmicEon/Electron-React-Material-SQLite。 我的系统: 视窗 10 节点 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 提到的样板,但仍然没有运气。当我尝试运行“纱线”时,我得到:

    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.

可能是我的环境出了点问题……请帮忙

【问题讨论】:

  • 嘿,我认为这可能与旧版本的 npm 有关,请检查此问题 => github.com/nodejs/node-gyp/issues/661,可能升级 npm 应该可以解决它
  • 我使用的 npm 版本高于该问题中报告的任何版本。我错过了什么吗?
  • 我知道你说你已经安装了构建工具,但为了确保 npm install --global --production windows-build-tools 这是全局正确的,不要一起使用纱线和节点,他们往往会把事情搞砸,在这之前只是 @ 987654327@

标签: node.js sqlite electron


【解决方案1】:

这个项目太老了,可能会发生:sqlite3 已经是 4.2 版本,并在 5.something 中续集。最好找一些近十年的起步项目。

也没有打字稿支持,也没有任何东西。您最好使用https://github.com/electron-react-boilerplate/electron-react-boilerplate,只需将要使用的续集和数据库添加到现有维护的样板中。

更新:Sqlite3 不适用于节点版本 15.x(和其他奇数版本),因此请更改为偶数版本(例如 14)。

【讨论】:

  • 感谢您抽出宝贵时间回复 Seti。问题不是反应/电子。我有一个工作版本。问题是当 SQLite 到位时。正如我在某些地方所读到的,必须编译 SQLite,但我似乎找不到正确的方法。我已经尝试了几篇文章/样板,但总是在这里遇到错误。 :((.
  • 这正是您正在使用的这个项目的问题 - 我也无法让 sqlite 使用它。但是当我将它添加到样板项目时,我给出了链接 - 它有效。主要是因为这个样板文件更好并且维护得更好,并且它们有特殊的地方可以放置本地编译的模块,以便它们正常工作
  • 好的,我尝试使用样板文件,但这次我很快就遇到了错误。 :( 请检查我帖子上的更新。感谢您的帮助
  • ,,Native dependencies could not be checked'' 其中package.json你添加了sqlite3?我在这个样板中要求您需要将这种包添加到app/package.json 而不是package.json。另外-theck 节点版本-如果不应该是奇数(因为它们经常导致问题)
  • 在将节点版本切换到 14 后,它工作了。我应该检查 sqlite3 节点兼容性,它就在那里......现在我只需要将其切换到 nodeJs,因为我现在不想投资于学习类型脚本。请创建将节点版本指定为的答案问题,我会接受它作为正确答案。
猜你喜欢
  • 2020-09-11
  • 2021-07-26
  • 1970-01-01
  • 2021-07-14
  • 2018-02-19
  • 2017-08-14
  • 1970-01-01
  • 2017-06-19
  • 2019-03-14
相关资源
最近更新 更多