【问题标题】:create-react-app command fails, how to undo a npm set registry commandcreate-react-app 命令失败,如何撤消 npm set registry 命令
【发布时间】:2019-01-02 21:26:57
【问题描述】:

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

  • http://localhost:4873/
  • https://www.npmjs.com/package/react-native-cli

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

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

关于如何修复它的任何建议。我的版本npmyarnnode

  • npm -v6.4.1
  • 节点 v10.14.2
  • yarn v1.12.3
  • brew v1.8.6 homebrew-core#cdd30, homebrew-cask#580d7

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

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:

【问题讨论】:

  • 您有~/.npmrc 文件吗?我认为您无法撤消对设置注册表的更改,但您可以删除该文件以将其重置为默认值。

标签: reactjs npm command-line-interface yarnpkg


【解决方案1】:

我遇到了类似的问题,我注册了http(不安全)。对我有用。

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

【讨论】:

    【解决方案2】:

    尝试删除~/.npmrc(如果存在)。当您运行 npm set registry 时,它通常会将设置保存到该文件中。

    【讨论】:

    • 但非常感谢你提醒我卸载并重新安装纱线。它现在恢复默认并正常工作:)
    猜你喜欢
    • 1970-01-01
    • 2021-04-28
    • 1970-01-01
    • 2017-02-09
    • 2022-10-01
    • 2021-08-10
    • 1970-01-01
    • 2018-01-09
    • 2020-08-11
    相关资源
    最近更新 更多