• npm install 报错 ‘proxy‘ config is set properly. See: ‘npm help config‘


    问题:使用 npm install 初始化项目依赖失败,报错 'proxy' config is set properly. See: 'npm help config'
    npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning ETIMEDOUT: request to https://registry.npmjs.org/vue-ref failed, reason: connect ETIMEDOUT 104.16.20.35:443
    npm WARN registry Using stale data from https://registry.npmjs.org/ due to a request error during revalidation.
    npm ERR! code ETIMEDOUT
    npm ERR! errno ETIMEDOUT
    npm ERR! network request to https://registry.npmjs.org/dom-closest failed, reason: connect ETIMEDOUT 104.16.22.35:443
    npm ERR! network This is a problem related to network connectivity.
    npm ERR! network In most cases you are behind a proxy or have bad network settings.
    npm ERR! network 
    npm ERR! network If you are behind a proxy, please make sure that the
    npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/dengzemiao/.npm/_logs/2022-11-14T04_51_31_564Z-debug.log
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    1、先查找一下自己的代理
    $ npm config get proxy
    $ npm config get npm config get https-proxy
    $ npm config get registry
    
    • 1
    • 2
    • 3
    2、然后将代理和缓存置空

    方式一:

    $ npm config set proxy false
    $ npm cache clean --force
    
    • 1
    • 2

    方式二:

    $ npm config set proxy null
    $ npm config set https-proxy null
    
    • 1
    • 2
    3、配置新的镜像源,选一个就行
    # 淘宝源(推荐)
    $ npm config set registry http://registry.npm.taobao.org/
    
    # 官方源
    $ npm config set registry http://registry.npmjs.org/
    $ npm config set registry https://registry.npmjs.org/
    
    # cnpm 源
    $ npm config set registry https://registry.cnpmjs.org/
    # 如果使用 cnpm,注意是否安装了 cnpm,cnpm 走推荐走的也是淘宝源
    $ npm install -g cnpm --registry=https://registry.npm.taobao.org/
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
  • 相关阅读:
    什么叫 “雪碧图”?
    怎么使用阿里巴巴关键字搜索工厂数据
    PPPoE配置
    浅谈人工智能怎么提升工作效率
    Apache Doris 系列: 入门篇-创建数据表
    在图片不被裁剪时opencv绕图片中任意点旋转任意角度
    【MySQL功法】第2话 · 数据库与数据表的基本操作
    编译Hudi
    Java 接口提速 --持续更新
    MySQL字段的字符类型该如何选择?千万数据下varchar和char性能竟然相差30%?
  • 原文地址:https://blog.csdn.net/zz00008888/article/details/127852233