zoukankan      html  css  js  c++  java
  • npm 代理设置及更换为国内下载源

    1.出错情况

    npm安装完成默认不走代理,所在如果公司内网是通过代理访问外部网站,npm则会出现安装插件失败情况

    2.设置代理

    • 命令行窗口输入:
    npm config set proxy http://server:port
    
    • 如果需要设https_proxy:
    npm config set https-proxy http://server:port
    
    • 设置了proxy就不需要设置https-proxy了。
    • 如果需要代理用户名和密码
    npm config set proxy http://username:password@server:port
    npm confit set https-proxy http://username:password@server:port
    

    3.取消代理

    npm config delete proxy
    或者
    npm config delete https-proxy
    

    4.修改源

    国外源速度不稳定,可设置国内淘宝源。

    • 查看现有源:
    npm config get registry
    
    • 设置淘宝源:
    npm config set registry https://registry.npm.taobao.org
    
    • 查看npm的设置
    npm config list
    或者
    npm config ls -l
    
    • 用新源更新一波package:
    npm update
    

    5.其他

    • 在设置配置属性时属性值默认是被存储于用户配置文件中,如果加上--global,则被存储在全局配置文件中。
    • 如果要查看npm的所有配置属性(包括默认配置),可以使用npm config ls -l。
    • 如果要查看npm的各种配置的含义,可以使用npm help config。
  • 相关阅读:
    VMware Workstation安装CentOs7固定ip地址
    使用阿里云oss
    使用Yapi展示你的api接口
    .net core使用MQTT
    CentOS 7服务器安装brook和bbr加速
    博客主题
    自定义控件
    winform数据绑定
    is as 运算符
    反射
  • 原文地址:https://www.cnblogs.com/jddreams/p/13434482.html
Copyright © 2011-2022 走看看