Vue 前端项目,Jenkins 构建过程中的一些报错记录,也适用于本地打包报错。
- 报错 spawn ENOMEM:
原因:内存不足
解决方案:以 vue-cli3 构建项目为例
本地打包:打包命令增加 npx --max_old_space_size=6144,size 可随意写
"scripts": {
"build": "npx --max_old_space_size=6144 vue-cli-service build --mode production"
}
Jenkins 构建:扩展服务器内存
以下为完整报错信息
node:internal/child_process:413
throw errnoException(err, 'spawn');
^
Error: spawn ENOMEM
at ChildProcess.spawn (node:internal/child_process:413:11)
at spawn (node:child_process:700:9)
at fork (node:child_process:166:10)
at ChildProcessWorker.initialize (/root/.jenkins/workspace/dev-sf-ays-fpd-web/node_modules/_jest-worker@25.5.0@jest-worker/build/workers/ChildProcessWorker.js:139:45)
at ChildProcessWorker._onExit (/root/.jenkins/workspace/dev-sf-ays-fpd-web/node_modules/_jest-worker@25.5.0@jest-worker/build/workers/ChildProcessWorker.js:268:12)
at ChildProcess.emit (node:events:520:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) {
errno: -12,
code: 'ENOMEM',
syscall: 'spawn'
}
- 报错 These dependencies were not found: *core-js/modules/xxxxx
本地打包正确的,不会报错,Jenkins 打包报错。怀疑 Jenkins 上包版本有问题,之前修改了 package.json 版本号 ^ 为 ~。再改回 ^,解决。
网友评论