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

在VS Code中安装Express时遇URL无效错误,求解决方法

安装Express时遇到ERR_INVALID_URL错误

在VS Code中执行npm i express命令安装Express框架时,出现以下错误:

PS C:\Users\Dell - i5\Desktop\starter> npm i express
(node:5044) [DEP0170] DeprecationWarning: The URL http://proxy-server-address:port is invalid. Future versions of Node.js will throw an error.
(Use `node --trace-deprecation ...` to show where the warning was created)
npm error code ERR_INVALID_URL
npm error Invalid URL
npm error A complete log of this run can be found in: C:\Users\Dell - i5\AppData\Local\npm-cache\_logs\2024-10-29T23_03_27_807Z-debug-0.log

已尝试多种解决方案并观看相关视频,但问题仍未解决,寻求帮助。


解决方案

  • 清理npm代理配置
    执行命令清除无效的代理设置:

    npm config delete proxy
    npm config delete https-proxy
    

    验证配置是否清除:

    npm config get proxy
    npm config get https-proxy
    

    若返回空值,说明代理已清理完成,重新执行npm i express尝试安装。

  • 检查系统环境变量
    打开系统环境变量设置,查找是否存在HTTP_PROXY或HTTPS_PROXY变量,若其值为无效的http://proxy-server-address:port,直接删除这些变量,重启终端后再执行安装命令。

  • 切换npm镜像源(可选)
    如果是网络访问问题导致,可切换到国内镜像源:

    npm config set registry https://registry.npmmirror.com/
    

    完成后再次执行npm i express。

  • 分析npm日志定位问题
    打开错误提示中给出的日志文件(C:\Users\Dell - i5\AppData\Local\npm-cache\_logs\2024-10-29T23_03_27_807Z-debug-0.log),查看详细的错误堆栈信息,确认是否有其他配置引发的URL无效问题。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 18:04:54