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

Vaadin 24本地构建正常,GitLab流水线npm安装失败求助

GitLab流水线Vaadin构建失败(npm EPROTO错误)解决办法

问题场景

  • 使用环境:Spring Boot 3.2.1、Vaadin 24.1.4
  • 本地执行命令gradle clean vaadinBuildFrontend build -DproductionMode=true -x test --stacktrace构建完全正常,但在GitLab流水线中执行相同命令时抛出异常:

    com.vaadin.flow.server.ExecutionFailedException: npm install. Some dependencies are not installed.

  • 日志附带核心错误:

    npm ERR ! code EPROTO
    npm ERR ! request to https://registery.npmjs.org/@open-wc%2fdedupe-mixin failed

解决方案

1. 修正npm仓库地址拼写错误

日志里的仓库地址registery.npmjs.org存在拼写错误,正确地址应为registry.npmjs.org(多一个字母s)。在GitLab流水线脚本中添加仓库修正命令:

npm config set registry https://registry.npmjs.org/

2. 解决网络代理/证书问题

GitLab Runner所在环境可能存在网络限制:

  • 若使用代理,在CI脚本中添加代理环境变量:
    export HTTP_PROXY=http://你的代理地址:端口
    export HTTPS_PROXY=http://你的代理地址:端口
    export NO_PROXY=localhost,127.0.0.1
    
  • 若为证书验证问题,可临时关闭npm严格SSL检查(生产环境建议配置合法证书):
    npm config set strict-ssl false
    

3. 配置GitLab依赖缓存

在.gitlab-ci.yml中添加缓存规则,复用已下载的前端依赖,避免重复下载失败:

cache:
  paths:
    - node_modules/
    - .gradle/

4. 升级npm版本

GitLab Runner环境的npm版本可能过低,存在兼容性问题,可在流水线中先升级npm:

npm install -g npm@latest

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.15 00:00:59