【问题标题】:NPM install java giving errorsNPM安装java给出错误
【发布时间】:2022-11-10 12:22:47
【问题描述】:

当试图运行下面的命令来为 NPM 安装 java 依赖项时,它会给出一大堆错误。

NPM 安装 -g java

有人请帮我纠正错误。

C:\WINDOWS\system32>npm i -g java

java@0.12.2 安装 C:\Dev\Software\npm-repository\npm\node_modules\java 节点gyp重建

C:\Dev\Software\npm-repository\npm\node_modules\java>if not defined npm_config_node_gyp (node "C:\Dev\Software\npm-repository\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Dev\Software\npm-repository\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: This is most likely not a problem with node-gyp or the package itself and
gyp ERR! stack is related to network connectivity. In most cases you are behind a proxy or have bad
gyp ERR! stack network settings.
gyp ERR! stack     at Request.<anonymous> (C:\Dev\Software\npm-repository\npm\node_modules\npm\node_modules\node-gyp\lib\install.js:171:21)
gyp ERR! stack     at Request.emit (events.js:315:20)
gyp ERR! stack     at Request.onRequestError (C:\Dev\Software\npm-repository\npm\node_modules\npm\node_modules\request\request.js:881:8)
gyp ERR! stack     at ClientRequest.emit (events.js:315:20)
gyp ERR! stack     at TLSSocket.socketErrorListener (_http_client.js:469:9)
gyp ERR! stack     at TLSSocket.emit (events.js:315:20)
gyp ERR! stack     at emitErrorNT (internal/streams/destroy.js:106:8)
gyp ERR! stack     at emitErrorCloseNT (internal/streams/destroy.js:74:3)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:80:21)
gyp ERR! System Windows_NT 10.0.19042
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Dev\\Software\\npm-repository\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Dev\Software\npm-repository\npm\node_modules\java
gyp ERR! node -v v14.16.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! java@0.12.2 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the java@0.12.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

【问题讨论】:

  • 您使用的是 VPN 还是类似的东西?
  • 是的,我已连接到公司网络...

标签: javascript java node.js npm npm-install


【解决方案1】:

尝试先执行npm i -g node-gyp,然后再执行上面的命令。

如果您遇到任何错误,请发表评论!

【讨论】:

  • 试过了......仍然得到同样的错误
【解决方案2】:

VPN 连接是这些npm i 错误的常见原因。尝试运行与 VPN 断开连接的命令。

【讨论】:

    【解决方案3】:

    我尝试通过禁用 VPN 来运行命令。下面是错误。

    npm ERR! code 1
    npm ERR! path C:Usersu245100React ProjectsCode
    ode_modulesjava
    npm ERR! command failed
    npm ERR! command C:WINDOWSsystem32cmd.exe /d /s /c node-gyp rebuild
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp info using node-gyp@9.1.0
    npm ERR! gyp info using node@16.17.0 | win32 | x64
    npm ERR! gyp info find Python using Python version 3.10.0 found at "C:Usersu245100AppDataLocalProgramsPythonPython310python.exe"
    npm ERR! gyp http GET https://nodejs.org/download/release/v16.17.0/node-v16.17.0-headers.tar.gz
    npm ERR! gyp WARN install got an error, rolling back install
    npm ERR! gyp ERR! configure error
    ssuer certificate
    npm ERR! gyp ERR! stack     at ClientRequest.<anonymous> (C:Usersu245100AppDataRoaming
    pm
    ode_modules
    pm
    ode_modulesminipass-fetchlibindex.js:130:14)
    npm ERR! gyp ERR! stack     at ClientRequest.emit (node:events:513:28)
    npm ERR! gyp ERR! stack     at TLSSocket.socketErrorListener (node:_http_client:481:9)
    npm ERR! gyp ERR! stack     at TLSSocket.emit (node:events:525:35)
    npm ERR! gyp ERR! stack     at emitErrorNT (node:internal/streams/destroy:157:8)
    npm ERR! gyp ERR! stack     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    npm ERR! gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
    npm ERR! gyp ERR! System Windows_NT 10.0.19042
    npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\u245100\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
    npm ERR! gyp ERR! cwd C:Usersu245100React ProjectsCode
    ode_modulesjava
    npm ERR! gyp ERR! node -v v16.17.0
    npm ERR! gyp ERR! node-gyp -v v9.1.0
    npm ERR! gyp ERR! not ok
    

    【讨论】:

      猜你喜欢
      • 2016-06-18
      • 2021-04-08
      • 1970-01-01
      • 2020-12-04
      • 1970-01-01
      • 2023-03-30
      • 2015-03-21
      • 2012-02-09
      相关资源
      最近更新 更多