【问题标题】:npm install serialport needs VS?npm install serialport 需要VS吗?
【发布时间】:2020-07-24 00:37:17
【问题描述】:

我一直在尝试为电子项目安装串行端口,但每当我使用 npm install serialport,我最终得到以下错误

E:\Windows\Desktop\Work\Electron\testing>npm install serialport

> @serialport/bindings@8.0.7 install E:\Windows\Desktop\Work\Electron\testing\node_modules\@serialport\bindings
> prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=13.6.0 runtime=node arch=x64 libc= platform=win32)

E:\Windows\Desktop\Work\Electron\testing\node_modules\@serialport\bindings>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS checking VS2019 (16.4.29709.97) 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 - missing any Windows SDK
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 **************************************************************
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
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:310:5)
gyp ERR! stack     at ChildProcess.emit (events.js:321:20)
gyp ERR! stack     at maybeClose (internal/child_process.js:1028:16)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd E:\Windows\Desktop\Work\Electron\testing\node_modules\@serialport\bindings
gyp ERR! node -v v13.6.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm WARN testing@1.0.0 No description
npm WARN testing@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @serialport/bindings@8.0.7 install: `prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @serialport/bindings@8.0.7 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\hp\AppData\Roaming\npm-cache\_logs\2020-04-11T08_43_12_018Z-debug.log

通读错误,我看到他们试图使用 VS,但这让我想知道为什么它需要 VS 开始。我浏览了serialport的文档,除了为gyp使用python2之外,他们没有说明任何先决条件,我已经将其添加到路径中。 如果你们能帮助我解决这个错误,那将是一个很大的帮助。

我目前正在使用 Node 的 V13.6.0。

【问题讨论】:

    标签: node.js visual-studio npm electron


    【解决方案1】:

    查看日志后,我意识到串行端口不是 VS 需要的东西。 当要安装串口时,它会检查当前使用的节点版本,然后根据它来构建。 为了做这样的事情,节点利用了所谓的 gyp,它利用了 python2 和 Visual Studio 的 C++ 开发环境来进行所需的更改, more on node-gyp。安装之后,一切似乎都很顺利。

    只是觉得如果有人遇到这样的小问题,在这里说出来会很方便...... ^^

    【讨论】:

    • 如何安装 Visual Studio 的 C++ 开发环境?是不是像安装整个 Visual Studio 应用程序一样?
    猜你喜欢
    • 2013-12-14
    • 2014-09-14
    • 2021-11-11
    • 2021-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-28
    • 1970-01-01
    相关资源
    最近更新 更多