react-native - 安装 ReactNative CLI 时出现 NPM 安装错误
问题描述
我希望将 React Native CLI 安装到我的 Windows 10 x64 PC。请帮忙。
发出此命令时遇到以下错误:
npm install -g react-native-cli
我收到的错误:
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to http://registry.npmjs.org/react-native-cli failed, reason: connect ECONNREFUSED 104.16.21.35:80 - Local (0.0.0.0:2623)
npm ERR! at ClientRequest.req.on.err (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:182:13)
npm ERR! at Socket.socketErrorListener (_http_client.js:391:9)
npm ERR! at Socket.emit (events.js:182:13)
npm ERR! at emitErrorNT (internal/streams/destroy.js:82:8)
npm ERR! at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
npm ERR! at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! { FetchError: request to http://registry.npmjs.org/react-native-cli failed, reason: connect ECONNREFUSED 104.16.21.35:80 - Local (0.0.0.0:2623)
npm ERR! at ClientRequest.req.on.err (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:182:13)
npm ERR! at Socket.socketErrorListener (_http_client.js:391:9)
npm ERR! at Socket.emit (events.js:182:13)
npm ERR! at emitErrorNT (internal/streams/destroy.js:82:8)
npm ERR! at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
npm ERR! at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! message:
npm ERR! 'request to http://registry.npmjs.org/react-native-cli failed, reason: connect ECONNREFUSED 104.16.21.35:80 - Local (0.0.0.0:2623)',
npm ERR! type: 'system',
npm ERR! errno: 'ECONNREFUSED',
npm ERR! code: 'ECONNREFUSED',
npm ERR! stack:
npm ERR! 'FetchError: request to http://registry.npmjs.org/react-native-cli failed, reason: connect ECONNREFUSED 104.16.21.35:80 - Local (0.0.0.0:2623)\n at ClientRequest.req.on.err (C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-fetch-npm\\src\\index.js:68:14)\n at ClientRequest.emit (events.js:182:13)\n at Socket.socketErrorListener (_http_client.js:391:9)\n at Socket.emit (events.js:182:13)\n at emitErrorNT (internal/streams/destroy.js:82:8)\n at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)\n at process._tickCallback (internal/process/next_tick.js:63:19)' }
npm ERR!
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\mwaqa\AppData\Roaming\npm-cache\_logs\2018-12-11T14_13_07_498Z-debug.log
解决方案
此问题可能与您的代理有关,首先,请尝试以下命令:
npm config set proxy null
npm config set https-proxy null
npm config set registry http://registry.npmjs.org/
然后执行
npm install -g react-native-cli
希望这会有所帮助。
推荐阅读
- php - Laravel:获取数据数组并使用 For 循环
- azure - Azure Max DB Connections on Release to Prod
- c# - 如何将csv转换为xml,其中csv中的每一列=标签的xml属性
- c# - 删除根节点但保留所有子节点
- laravel - Laravel 中的唯一验证取决于用户 ID
- node.js - 如何在 Discord.js 中创建输出文件下一行的命令
- node.js - npm 错误!安装电子打包器
- c# - 使用 WinSCP .NET 程序集时,...\WinSCP.exe 的版本与此程序集的版本不匹配
- wordpress - 更新到最新的 wordpress 5.0 后,联系 7 表格导致我的网站出现错误
- go - 从 Golang 中的结构更新值