首页 > 解决方案 > 获取 npm 错误!退出错误代码:128

问题描述

我使用以下链接react-native-vector-icons在我的 react native 项目中尝试了 'RNVectorIcons' 包。我在终端中使用了pod install命令。但我在终端窗口中收到以下错误。

Analyzing dependencies
Fetching podspec for `RNVectorIcons` from `../node_modules/react-native-vector-icons`
Downloading dependencies
Installing RNVectorIcons (4.6.0)
Installing React (0.11.0)
[!] /bin/bash -c 
set -e
npm install --production

npm WARN deprecated connect@2.8.3: connect 2.x series is deprecated
npm WARN deprecated babel-core@5.8.21: Babel 5 is no longer being maintained. Upgrade to Babel 6.
npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated line-numbers@0.2.0: Copy its ~20 LOC directly into your code instead.
npm WARN deprecated tough-cookie@1.2.0: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN deprecated coffee-script@1.6.3: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN deprecated formatio@1.1.1: This package is unmaintained. Use @sinonjs/formatio instead
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t git://github.com/facebook/react.git
npm ERR! 
npm ERR! undefined
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/macmini1/.npm/_logs/2018-06-21T12_59_11_182Z-debug.log

我的package.json文件如下所示:

{
  "name": "sample",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "gulp": "gulp"
  },
  "dependencies": {
    "eslint": "4.19.1",
    "eslint-config-airbnb": "16.1.0",
    "eslint-config-airbnb-base": "12.1.0",
    "eslint-config-rallycoding": "3.2.0",
    "eslint-import-resolver-webpack": "0.10.0",
    "eslint-plugin-import": "2.12.0",
    "eslint-plugin-jsx-a11y": "6.0.3",
    "eslint-plugin-react": "7.8.2",
    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-native-vector-icons": "4.6.0",
    "react-navigation": "2.3.1"
  },
  "devDependencies": {
    "babel-jest": "23.0.1",
    "babel-preset-react-native": "4.0.0",
    "jest": "23.1.0",
    "react-test-renderer": "16.3.1"
  },
  "jest": {
    "preset": "react-native"
  }

debug.log文件是

1609 verbose stack Error: exited with error code: 128
1609 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/util/finished.js:12:19)
1609 verbose stack     at ChildProcess.emit (events.js:182:13)
1609 verbose stack     at maybeClose (internal/child_process.js:961:16)
1609 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
1610 verbose cwd /Users/macmini1/Library/Caches/CocoaPods/Pods/Release/React/0.11.0-ab1a2
1611 verbose Darwin 17.0.0
1612 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--production"
1613 verbose node v10.4.1
1614 verbose npm  v6.1.0
1615 error Error while executing:
1615 error /usr/bin/git ls-remote -h -t git://github.com/facebook/react.git
1615 error
1615 error undefined
1615 error exited with error code: 128
1616 verbose exit [ 1, true ]

如何解决这个问题?

标签: iosreactjsreact-native

解决方案


你能提供调试日志的内容吗?您是在添加此软件包后才遇到此问题吗?您也可以发布package.json文件的内容吗?

也请看一下这个问题/解决方案,它看起来确实像你遇到的问题:react-native init AwesomeProject 无法连接到 github.com

更新

它可能与访问 github 的方式有关。您可以在重试之前尝试运行以下命令吗?

git config --global url."https://".insteadOf git://

推荐阅读