【问题标题】:Vue CLI SOCKET_TIMEOUT error creating new project (npm error)Vue CLI SOCKET_TIMEOUT 创建新项目时出错(npm 错误)
【发布时间】:2021-03-24 23:26:28
【问题描述】:

所以基本上我正在尝试使用vue create vue-first-app 设置一个新的 Vue 项目,我最终在下面出现了这个错误。我尝试使用 npm install -timeout=9999999 增加超时。我还尝试使用npm cache clean --force 清理 npm Cashe,但没有帮助。有谁知道解决这个问题的方法吗?

    Vue CLI v4.5.9
✨  Creating project in /home/marius/vue/vue-first-app.
????  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/mkdirp failed, reason: Socket timeout

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/marius/.npm/_logs/2020-12-14T09_54_21_447Z-debug.log
 ERROR  command failed: npm install --loglevel error --legacy-peer-deps

【问题讨论】:

  • 遇到同样的问题!

标签: node.js vue.js npm


【解决方案1】:

试试

任一

  1. sudo npm cache clean -f
  2. npm update
  3. npm update -g @vue/cli
  4. vue create vue-first-app

将 npm 注册表 url 指向 http

npm config set registry="http://registry.npmjs.org/"

然后重新运行你的 vue cli 命令:

vue create vue-first-app

【讨论】:

    【解决方案2】:

    这可能会对你有所帮助。

    1. 检查您是否有可用的互联网连接(检查防火墙是否没有阻止连接请求)

    2. 尝试去 npm 配置文件并从那里更改时间。当这两个原因之一发生时,通常会导致此问题。路径:installationDirectory\nodejs\node_modules\npm 并打开 .npmrc 文件并尝试从那里更改超时。

    另请参阅:https://docs.npmjs.com/common-errors

    【讨论】:

      【解决方案3】:

      遇到同样的问题。

      对我来说,使用 sudo 有效。

      sudo vue create vue-first-app
      

      祝你好运!

      【讨论】:

        【解决方案4】:

        我遇到了类似的问题,对我来说,它可以在配置 .vuerc 中将 useTaobaoRegistry 更改为 false,它应该位于 C:/User/your_name/

        { "packageManager": "npm", "使用淘宝注册": false }

        感谢 fangbinwei 的解决方案: https://github.com/vuejs/vue-cli/issues/6003#issuecomment-716158880

        【讨论】:

          猜你喜欢
          • 2023-03-20
          • 1970-01-01
          • 2020-01-16
          • 2020-11-01
          • 2020-12-29
          • 1970-01-01
          • 1970-01-01
          • 2017-01-25
          • 1970-01-01
          相关资源
          最近更新 更多