使用npm安装node-pty libaray时出错

问题描述 投票:0回答:1

根据文档使用npm安装node.js的node-pty模块时出现以下错误我使用以下命令

npm i node-pty -g
我的系统和节点版本列在下面,窗口构建工具也安装版本2017和2015
npm i node-gyp -g
命令也成功运行。
操作系统:Windows 10 Pro
版本:18363
节点:12.16.3
npm:6.14.4

> [email protected] install C:\Program Files\nodejs\node_modules\node-pty
> node scripts/install.js


C:\Users\HP\AppData\Roaming\nvm\v12.16.3\node_modules\node-pty>if not defined npm_config_node_gyp (node "C:\Users\HP\AppData\Roaming\nvm\v12.16.3\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\HP\AppData\Roaming\nvm\v12.16.3\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  conpty.cc
  path_util.cc
  win_delay_load_hook.cc
C:\\Users\\HP\\AppData\\Local\\node-gyp\\Cache\\12.16.3\\x64\\node.lib : fatal error LNK1127: library is corrupt [C:\Users\HP\AppData\Roaming\nvm\v12.16.3\node_modules\node-pty\build\conpty.vcxproj]
  conpty_console_list.cc
  win_delay_load_hook.cc
C:\\Users\\HP\\AppData\\Local\\node-gyp\\Cache\\12.16.3\\x64\\node.lib : fatal error LNK1127: library is corrupt [C:\Users\HP\AppData\Roaming\nvm\v12.16.3\node_modules\node-pty\build\conpty_console_list.vcxproj]
  AgentLocation.cc
  winpty.cc
  BackgroundDesktop.cc
  Buffer.cc
  DebugClient.cc
  GenRandom.cc
  OwnedHandle.cc
  StringUtil.cc
  WindowsSecurity.cc
  WindowsVersion.cc
  WinptyAssert.cc
  WinptyException.cc
  WinptyVersion.cc
  win_delay_load_hook.cc
    Creating library C:\Users\HP\AppData\Roaming\nvm\v12.16.3\node_modules\node-pty\build\Release\winpty.lib and object C:\Users\HP\AppData\Roaming\nvm\v12.16.3\node_modules\node-pty\build\Release\winpty.exp
  winpty.vcxproj -> C:\Users\HP\AppData\Roaming\nvm\v12.16.3\node_modules\node-pty\build\Release\\winpty.dll
  Agent.cc
  AgentCreateDesktop.cc
  ConsoleFont.cc
  ConsoleInput.cc
  ConsoleInputReencoding.cc
  ConsoleLine.cc
  DebugShowInput.cc
  DefaultInputMap.cc
  EventLoop.cc
  InputMap.cc
  LargeConsoleRead.cc
  NamedPipe.cc
  Scraper.cc
  Terminal.cc
  Win32Console.cc
  Win32ConsoleBuffer.cc
  main.cc
  BackgroundDesktop.cc
  Buffer.cc
  DebugClient.cc
  GenRandom.cc
  OwnedHandle.cc
  StringUtil.cc
  WindowsSecurity.cc
  WindowsVersion.cc
  WinptyAssert.cc
  WinptyException.cc
  WinptyVersion.cc
  win_delay_load_hook.cc
  winpty-agent.vcxproj -> C:\Users\HP\AppData\Roaming\nvm\v12.16.3\node_modules\node-pty\build\Release\\winpty-agent.exe
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\HP\AppData\Roaming\nvm\v12.16.3\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:310:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\HP\\AppData\\Roaming\\nvm\\v12.16.3\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\HP\AppData\Roaming\nvm\v12.16.3\node_modules\node-pty
gyp ERR! node -v v12.16.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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-05-29T09_24_34_336Z-debug.log
node.js npm-install node-pty
1个回答
0
投票

因为windows机器不支持node-pty。

node-pty 仅适用于 linux 和 mac,但如果您想在 Windows 中安装 Node pty,您可以使用 windows conpty API 安装它,在他们的 npm 页面中提到。

请参阅他们的文档 在此输入链接描述

© www.soinside.com 2019 - 2024. All rights reserved.