记录docker容器k8s构建前端应用失败问题原因

博客内容讲述了在Docker和Kubernetes(K8s)环境中构建Vue应用时遇到的构建失败问题,主要原因是某些生产环境配置不兼容、npm镜像地址未正确设置、Dockerfile和配置文件不稳以及代码格式和校验问题。错误日志显示缺少依赖,建议检查并安装缺失模块,优化webpack插件以提高docker兼容性,同时确保代码规范和监控工具的使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

docker k8s构建平台构建应用失败原因

  1. vue.config.js 生产环境谨慎配置打包优化插件(docker兼容性较差) 如 terser-webpack-plugin  uglifyjs-webpack-plugin。例外:HappyPack可用
  2. npmrc 配置合适的镜像地址
  3. Dockerfile 配置保持稳定
  4. nginx.conf配置保持稳定
  5. .env配置保持稳定有效
  6. git忽略大小写 本地改文件夹及文件名称须设置
git config core.ignorecase false

    7.eslint格式化配置,代码校验不通过会导致构建失败

  编辑器vscode 配置 eslint插件  git-precommit配置 husky+lint-staged

    8.建议加上代码监控 自研或者使用sentry(商业化收费)等工具

 

失败日志如下

ERROR Failed to compile with 5 errors16:57:08
16:57:08builder: Extracted theme color css content length: 32920
16:57:08builder: npm ERR! Exit status 1
16:57:08builder: * @/views/sku/packageOrBom in ./src/config/router.config.js
16:57:08builder: These dependencies were not found:
16:57:08builder: npm ERR! code ELIFECYCLE
16:57:08builder: npm ERR! errno 1
16:57:08builder: * @/views/sku/unitConversion in ./src/config/router.config.js
16:57:08builder: * @/views/sku/taxCodeTaxRate in ./src/config/router.config.js
16:57:08builder: ERROR Build failed with errors.
16:57:08builder: To install them, you can run: npm install --save @/views/accountingEntries/accountingEntries @/views/sku/packageOrBom @/views/sku/taxCodeTaxRate @/views/sku/unitConversion @/views/workbench/cashierWorkbench
16:57:08builder:
16:57:08builder: * @/views/accountingEntries/accountingEntries in ./src/config/router.config.js
16:57:08builder: npm ERR! Failed at the vue-antd-pro@2.1.0 build:dev script.
16:57:08builder: npm ERR!
16:57:08builder: npm ERR! Exit status 1
16:57:08builder: npm ERR! vue-antd-pro@2.1.0 build:dev: `vue-cli-service build --mode dev`
16:57:08builder: npm ERR! vue-antd-pro@2.1.0 postinstall: `npm run build:dev`
16:57:08builder: * @/views/workbench/cashierWorkbench in ./src/config/router.config.js
16:57:08builder: npm ERR! errno 1
16:57:08builder: npm ERR! /tmp/npmcache.pfe1Z/_logs/2021-01-13T08_57_08_567Z-debug.log
16:57:08builder: npm ERR!
16:57:08builder: npm ERR! Failed at the vue-antd-pro@2.1.0 postinstall script.
16:57:08builder:
16:57:08builder: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
16:57:08builder:
16:57:08builder: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
16:57:08builder: npm ERR! A complete log of this run can be found in:
16:57:08builder: npm ERR! code ELIFECYCLE
16:57:09builder: npm ERR! A complete log of this run can be found in:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值