安装react-native时npm安装挂起

vltsax25  于 2022-11-24  发布在  React
关注(0)|答案(1)|浏览(170)

我的npm install昨天工作正常,但现在它挂了,因为一些我不明白的原因。
我的package.json

{
 "name": "Vanitee",
 "version": "0.0.1",
 "private": true,
 "scripts": {
 "start": "node node_modules/react-native/local-cli/cli.js start",
 "test": "jest",
 "flow": "flow --show-all-errors"
  },
"dependencies": {
 "@tradle/react-native-http": "^2.0.0",
 "assert": "^1.4.1",
 "babel-plugin-transform-remove-console": "^6.9.0",
 "browserify-zlib": "^0.1.4",
 "console-browserify": "^1.1.0",
 "constants-browserify": "^1.0.0",
 "dns.js": "^1.0.1",
 "domain-browser": "^1.2.0",
 "events": "^1.1.1",
 "https-browserify": "0.0.1",
 "mobx": "^3.6.2",
 "mobx-react": "^4.4.3",
 "moment": "^2.22.0",
 "path-browserify": "0.0.0",
 "process": "^0.11.10",
 "querystring-es3": "^0.2.1",
 "react": "^16.0.0",
 "react-native": "^0.50.4",
 "react-native-crypto": "^2.1.2",
 "react-native-dropdownalert": "^3.4.0",
 "react-native-easy-toast": "^1.1.0",
 "react-native-htmlview": "^0.12.1",
 "react-native-http": "github:tradle/react-native-http#834492d",
 "react-native-image-progress": "^1.0.1",
 "react-native-keyboard-spacer": "^0.4.1",
 "react-native-level-fs": "^3.0.0",
 "react-native-lightbox": "^0.7.0",
 "react-native-maps": "^0.19.0",
 "react-native-modal": "^4.1.1",
 "react-native-os": "^1.1.0",
 "react-native-randombytes": "^3.0.0",
 "react-native-star-rating": "^1.0.8",
 "react-native-styled-image-progress": "0.0.2",
 "react-native-swiper": "^1.5.13",
 "react-native-tcp": "^3.3.0",
 "react-native-timer": "^1.3.1",
 "react-native-udp": "^2.3.1",
 "react-native-vector-icons": "^4.5.0",
 "react-navigation": "^1.0.0-beta.27",
 "readable-stream": "^1.0.33",
 "stream-browserify": "^1.0.0",
 "timers-browserify": "^1.4.2",
 "tty-browserify": "0.0.0",
 "url": "^0.10.3",
 "util": "^0.10.3",
 "vm-browserify": "0.0.4"
},
"devDependencies": {
 "babel-jest": "21.2.0",
 "babel-plugin-transform-decorators-legacy": "^1.3.4",
 "babel-preset-react-native": "4.0.0",
 "flow-bin": "^0.56.0",
 "jest": "21.2.1",
 "react-test-renderer": "16.0.0",
 "rn-nodeify": "github:tradle/rn-nodeify"
},
"jest": {
 "preset": "react-native"
},
"react-native": {
 "zlib": "browserify-zlib",
 "console": "console-browserify",
 "constants": "constants-browserify",
 "crypto": "react-native-crypto",
 "dns": "dns.js",
 "net": "react-native-tcp",
 "domain": "domain-browser",
 "http": "@tradle/react-native-http",
 "https": "https-browserify",
 "os": "react-native-os",
 "path": "path-browserify",
 "querystring": "querystring-es3",
 "fs": "react-native-level-fs",
 "_stream_transform": "readable-stream/transform",
 "_stream_readable": "readable-stream/readable",
 "_stream_writable": "readable-stream/writable",
 "_stream_duplex": "readable-stream/duplex",
 "_stream_passthrough": "readable-stream/passthrough",
 "dgram": "react-native-udp",
 "stream": "stream-browserify",
 "timers": "timers-browserify",
 "tty": "tty-browserify",
 "vm": "vm-browserify",
 "tls": false
},
"browser": {
 "zlib": "browserify-zlib",
 "console": "console-browserify",
 "constants": "constants-browserify",
 "crypto": "react-native-crypto",
 "dns": "dns.js",
 "net": "react-native-tcp",
 "domain": "domain-browser",
 "http": "@tradle/react-native-http",
 "https": "https-browserify",
 "os": "react-native-os",
 "path": "path-browserify",
 "querystring": "querystring-es3",
 "fs": "react-native-level-fs",
 "_stream_transform": "readable-stream/transform",
 "_stream_readable": "readable-stream/readable",
 "_stream_writable": "readable-stream/writable",
 "_stream_duplex": "readable-stream/duplex",
 "_stream_passthrough": "readable-stream/passthrough",
 "dgram": "react-native-udp",
 "stream": "stream-browserify",
 "timers": "timers-browserify",
 "tty": "tty-browserify",
 "vm": "vm-browserify",
 "tls": false
}
}

我的npm install --verbose给出了以下结果

我尝试过的解决方案:

  • npm cache clean --force && npm install
  • 删除了我的package-lock.json,并尝试了npm install作为建议,在这个线程https://github.com/npm/npm/issues/17228
  • 我试过使用npm只安装react-native-http,但它仍然挂起

此外,在我的npm挂起后,我的活动监视器显示npm的cpu使用率为100

jvidinwx

jvidinwx1#

尝试:
前往设置〉网络和互联网〉代理,并找到地址和端口。
MAC地址:https://support.apple.com/guide/mac-help/enter-proxy-server-settings-on-mac-mchlp25912/13.0/mac/13.0
步骤2:根据您的计算机转到命令提示符或终端(提示:按Win + R并键入cmd)。在命令提示符下,键入以下命令npm config set proxy http://@ proxy-server-url〉:然后配置设置https代理http://@代理服务器URL〉:.用户名和密码真的是不需要的,10次中有9次,最后2次就足够了。Proxy-server-url是你的地址,你的port是端口号。一旦设置好了,关闭命令提示符并重新打开它。瞧!你现在可以安装所有的软件包了。
参考:https://medium.com/@ogbemudiatimothy/using-npm-install-behind-a-corporate-proxy-server-db150c128899
如果不起作用,请尝试运行以下命令:
npm配置设置代理http://:80
npm配置设置https-proxy https://:80

相关问题