0

自过去 2 天以来,我一直遇到此错误。任何帮助将不胜感激。我正在尝试重建应用程序以使用serialport npm 包。节点版本:14.16.1。

我想与带有反应的电子一起使用包串行端口。但是当我运行命令 .\node_modules.bin\electron-rebuild.cmd 时,我收到以下错误:

⠹ Building module: bindings, Completed: 0Attempting to build a module with a space in the path
See https://github.com/nodejs/node-gyp/issues/65#issuecomment-368820565 for reasons why this may not work
⠴ Building module: bindings, Completed: 0gyp info find Python using Python version 3.9.4 found at "C:\Users\Family\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe"
⠙ Building module: bindings, Completed: 0gyp ERR! find VS
gyp ERR! find VS msvs_version was set from command line or npm config
gyp ERR! find VS - looking for Visual Studio version 2015
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS checking VS2019 (16.9.31205.134) found at:
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community" 
gyp ERR! find VS - found "Visual Studio C++ core features"
gyp ERR! find VS - found VC++ toolset: v142
gyp ERR! find VS - found Windows SDK: 10.0.19041.0
gyp ERR! find VS - msvs_version does not match this version
gyp ERR! find VS checking VS2017 (15.9.28307.1500) found at:
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp ERR! find VS - found "Visual Studio C++ core features"
gyp ERR! find VS - found VC++ toolset: v141
gyp ERR! find VS - found Windows SDK: 10.0.17763.0
gyp ERR! find VS - msvs_version does not match this version
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use  
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS 
gyp ERR! find VS valid versions for msvs_version:
gyp ERR! find VS - "2019"
gyp ERR! find VS - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp ERR! find VS - "2017"
gyp ERR! find VS - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
✖ Rebuild Failed

An unhandled error occurred inside electron-rebuild
node-gyp failed to rebuild 'C:\MERN Work\Electron Apps\React_Only\simple-electron-react\node_modules\@serialport\bindings'.
Error: Could not find any Visual Studio installation to use



Error: node-gyp failed to rebuild 'C:\MERN Work\Electron Apps\React_Only\simple-electron-react\node_modules\@serialport\bindings'.
Error: Could not find any Visual Studio installation to use


    at ModuleRebuilder.rebuildNodeGypModule (C:\MERN Work\Electron Apps\React_Only\simple-electron-react\node_modules\electron-rebuild\lib\src\module-rebuilder.js:193:19)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Rebuilder.rebuildModuleAt (C:\MERN Work\Electron Apps\React_Only\simple-electron-react\node_modules\electron-rebuild\lib\src\rebuild.js:190:9)
    at async Rebuilder.rebuild (C:\MERN Work\Electron Apps\React_Only\simple-electron-react\node_modules\electron-rebuild\lib\src\rebuild.js:152:17)  
    at async C:\MERN Work\Electron Apps\React_Only\simple-electron-react\node_modules\electron-rebuild\lib\src\cli.js:146:9

顺便说一句,我已经手动和使用 npm 命令安装了 microsoft 构建工具:npm install --global windows-build-tools。这是我通过.exe手动安装的:

在此处输入图像描述

一直在使用这个https://github.com/bradtraversy/simple-electron-react样板。

4

1 回答 1

0
按照这些步骤为我解决了这个问题:
  1. 安装最新的 Visual Studio 工具包和 visual-studio-installer。
  2. node-gyp使用管理员权限全局安装。
  3. 安装electron-builder@22.11.1
规格 :

Windows 10, Electron :13.0.0, node : v14.16.1 , yarn : 1.22.10,电子反应样板


于 2021-05-30T20:15:51.750 回答