【问题标题】:how to increase waiting timeout from 30000 ms to 60000 ms of npm installing time in ubuntu如何在 ubuntu 中将 npm 安装时间的等待超时从 30000 毫秒增加到 60000 毫秒
【发布时间】:2020-08-24 08:54:45
【问题描述】:

由于我的互联网连接速度很慢,我无法从 npm 安装软件包,因为 npm 返回错误为

npm 错误!尝试获取 https://registry.npmjs.org/create-react-app 时响应超时(超过 30000 毫秒)

我希望如果我将等待时间增加到一分钟或更长时间,错误可能会得到修复。而且由于我使用的是 ubuntu 18.04,所以我想不出办法来做到这一点。

【问题讨论】:

    标签: node.js reactjs npm create-react-app npm-install


    【解决方案1】:

    我不知道与您的问题有多相似。但是我在执行npm install -g npm-check-updates后执行以下命令时遇到了问题:

    ncu -u
    

    我只是在命令完成后不断增加超时时间。

    ncu -u --timeout 100000
    

    【讨论】:

      【解决方案2】:

      将此添加到您的 .npmrc 文件中:

      timeout=60000
      

      【讨论】:

      • 应该在您的主文件夹中:/home/yourusername/.npmrc。如果您执行man npm,您可以看到它也尝试加载:$HOME/.npmrc Global Configs: The file found at ../etc/npmrc (from the node executable, by default this resolves to /usr/local/etc/npmrc) will be parsed if it is found.
      • @Lioul 如果我的回答解决了您的问题,请将其标记为已接受
      • 这解决了我在将包发布到 npm 时的超时问题。
      • @arc 体验为主,+调试
      • @Ron +1 给您的体验。它也接受超时参数(--timeout),以毫秒为值。但我的失败抱怨无效参数为字符串
      【解决方案3】:

      使用以下命令更新 npm 配置:

      npm config set fetch-retry-maxtimeout 60000 -g
      

      请参阅documentationavailable options

      【讨论】:

        【解决方案4】:

        不使用这些 Windows 解决方案。然后,我添加了 --timeout 作为参数来执行。

        例如:

        npx npm-check-updates --timeout 200000
        

        【讨论】:

          【解决方案5】:

          这个答案有点晚了,但对未来的读者很有用。

          As of NPM v7有一个--fetch-timeout 选项。

          当你运行npm install 时添加--fetch-timeout

          npm install --fetch-timeout=60000
          

          还有一个.npmrc configuration setting called fetch-timeout。您可以将以下内容添加到~/.npmrc

          fetch-timeout=60000
          

          或运行以下命令

          npm config set fetch-timeout 60000
          

          【讨论】:

            猜你喜欢
            • 2016-08-11
            • 1970-01-01
            • 2018-12-22
            • 2023-03-29
            • 1970-01-01
            • 2022-12-29
            • 2018-12-21
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多