You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 20.04环境下无法通过npm安装discord.js求助

Ubuntu 20.04网络类错误排查方案

已确认你网络正常、防火墙关闭且未使用IPv6,针对这类常见问题,可按以下步骤排查:

1. 重置软件源配置

  • 备份现有源文件:
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
    
  • 替换为国内稳定镜像源(以阿里云为例),编辑源文件:
    sudo nano /etc/apt/sources.list
    
    将文件内容替换为:
    deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    
  • 保存退出后执行源更新:
    sudo apt update
    

2. 修正DNS配置

  • 查看当前DNS设置:
    cat /etc/resolv.conf
    
  • 若DNS地址异常,临时修改为公共DNS:
    sudo nano /etc/resolv.conf
    
    添加以下内容:
    nameserver 8.8.8.8
    nameserver 114.114.114.114
    
  • 配置永久DNS(避免重启失效):
    sudo nano /etc/systemd/resolved.conf
    
    修改对应字段:
    [Resolve]
    DNS=8.8.8.8 114.114.114.114
    
    重启生效:
    sudo systemctl restart systemd-resolved
    

3. 深度验证网络连通性

  • 测试镜像服务器可达性:
    ping mirrors.aliyun.com -c 4
    
  • 测试端口连通性(HTTP端口80):
    nc -zv mirrors.aliyun.com 80
    

内容的提问来源于stack exchange,提问作者m_hm0ud

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 23:35:22