【问题标题】:Socket timeout when trying to create a new vue project with vue-cli尝试使用 vue-cli 创建新的 vue 项目时的套接字超时
【发布时间】:2021-03-18 16:45:32
【问题描述】:

我在使用 vue-cli 创建新的 Vue 项目时遇到错误。每次创建因“套接字超时”而失败但请求不同时?我使用 nvm 更新了节点并安装了最新的 vue-cli。

终端显示如下:

Vue CLI v4.5.9
✨  Creating project in /Users/me/Documents/GitHub/myproject.
????  Initializing git repository...
⚙️  Installing CLI plugins. This might take a while...

npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! request to https://registry.npm.taobao.org/cosmiconfig failed, reason: Socket timeout

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/me/.npm/_logs/2020-12-07T11_02_37_391Z-debug.log
 ERROR  command failed: npm install --loglevel error --legacy-peer-deps

在日志文件的第 4900 行附近创建往往会失败。这些是日志文件中的最后几行:

4875 timing idealTree:node_modules/webpack-dev-server/node_modules/anymatch/node_modules/normalize-path Completed in 0ms
4876 timing idealTree:buildDeps Completed in 164233ms
4877 timing idealTree:fixDepFlags Completed in 10ms
4878 timing idealTree Completed in 164265ms
4879 timing command:install Completed in 164269ms
4880 verbose type system
4881 verbose stack FetchError: request to https://registry.npm.taobao.org/cosmiconfig failed, reason: Socket timeout
4881 verbose stack     at ClientRequest.<anonymous> (/Users/me/.nvm/versions/node/v15.3.0/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js:97:14)
4881 verbose stack     at ClientRequest.emit (node:events:376:20)
4881 verbose stack     at TLSSocket.socketErrorListener (node:_http_client:490:9)
4881 verbose stack     at TLSSocket.emit (node:events:388:22)
4881 verbose stack     at emitErrorNT (node:internal/streams/destroy:188:8)
4881 verbose stack     at emitErrorCloseNT (node:internal/streams/destroy:153:3)
4881 verbose stack     at processTicksAndRejections (node:internal/process/task_queues:80:21)
4882 verbose cwd /Users/me/Documents/GitHub/myproject
4883 verbose Darwin 19.6.0
4884 verbose argv "/Users/me/.nvm/versions/node/v15.3.0/bin/node" "/Users/me/.nvm/versions/node/v15.3.0/bin/npm" "install" "--loglevel" "error" "--legacy-peer-deps"
4885 verbose node v15.3.0
4886 verbose npm  v7.0.14
4887 error code ERR_SOCKET_TIMEOUT
4888 error errno ERR_SOCKET_TIMEOUT
4889 error request to https://registry.npm.taobao.org/cosmiconfig failed, reason: Socket timeout
4890 verbose exit 1

【问题讨论】:

    标签: vue.js vue-cli


    【解决方案1】:

    好的,我刚刚将我的操作系统更新到 Big Sur,现在它似乎可以工作了。

    【讨论】:

      【解决方案2】:

      更新到 Big Sur 对我没有帮助。 然而,这有所帮助:

      sudo npm 卸载 -g vue sudo npm 卸载 -g vue-cli 须藤 npm 卸载 -g @vue/cli sudo npm 缓存清理 --force sudo npm install -g vue sudo npm install -g @vue/cli

      【讨论】:

        【解决方案3】:

        我也遇到过这个。通过第一次运行修复它

        vue config -e
        

        然后将此属性设置为false:

        {
          "useTaobaoRegistry": false
        }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-01-16
          • 2019-12-21
          • 2021-06-04
          • 2021-03-24
          • 2019-12-27
          • 1970-01-01
          • 2019-01-26
          • 2021-09-15
          相关资源
          最近更新 更多