首页 > 解决方案 > create-react-app 命令失败,如何撤消 npm set registry 命令

问题描述

我不小心在我的终端 npm set registry 上运行了这个命令:

在探索 react-native 时,它​​现在弄乱了我的create-react-appyarn 命令(创建一个反应启动器应用程序)我知道这一点,因为我收到了这个错误

FetchError:对http://localhost:4873/yarn的请求失败,原因:连接 ECONNREFUSED 127.0.0.1:4873 ...

有关如何修复它的任何建议。我的版本npm,,,yarnnode

这是我尝试重新安装create-react-appcli时的完整错误代码

npm install -g create-react-app yarn
Password:
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to http://localhost:4873/yarn failed, reason: connect ECONNREFUSED 127.0.0.1:4873
npm ERR!     at ClientRequest.req.on.err (/usr/local/lib/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:392: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://localhost:4873/yarn failed, reason: connect ECONNREFUSED 127.0.0.1:4873
npm ERR!     at ClientRequest.req.on.err (/usr/local/lib/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:392: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://localhost:4873/yarn failed, reason: connect ECONNREFUSED 127.0.0.1:4873',
npm ERR!   type: 'system',
npm ERR!   errno: 'ECONNREFUSED',
npm ERR!   code: 'ECONNREFUSED',
npm ERR!   stack:
npm ERR!    'FetchError: request to http://localhost:4873/yarn failed, reason: connect ECONNREFUSED 127.0.0.1:4873\n    at ClientRequest.req.on.err (/usr/local/lib/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:392: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:

标签: reactjsnpmcommand-line-interfaceyarnpkg

解决方案


我遇到了类似的问题,我已经注册http(不安全)。为我工作。

$ npm config set registry http://registry.npmjs.org/
$ npm config set strict-ssl false

推荐阅读