在要求输入邮箱的文本域,请填写真实的邮件地址。非真实邮件地址,将收不到回复信息。

Docker构建VUE项目NPM构建134异常

Docker 清风 1215℃ 0评论

背景

一个前端的VUE项目,需要打一个Docker的镜像离线包。通过命令行构建镜像,通过等待比较长的时间后,NPM构建抛出异常。

异常内容

以下是关于这次异常的详细信息:

docker构建VUE项目异常图片
=> ERROR [build-stage 10/10] RUN npm run build                                                                 1222.9s
------
 > [build-stage 10/10] RUN npm run build:
#18 7.649
#18 7.649 > vue-antd-admin@0.7.4 build /app
#18 7.649 > vue-cli-service build
#18 7.649
#18 24.59
#18 24.60 -  Building for production...
#18 1221.3
#18 1221.3 <--- Last few GCs --->
#18 1221.3
#18 1221.3 [24:0x40d39c0]  1206698 ms: Mark-sweep (reduce) 986.8 (995.9) -> 986.1 (997.4) MB, 6393.8 / 0.1 ms  (average mu = 0.076, current mu = 0.019) allocation failure scavenge might not succeed
#18 1221.3
#18 1221.3
#18 1221.3 <--- JS stacktrace --->
#18 1221.3
#18 1221.3 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
#18 1221.5  1: 0xa18da8 node::Abort() [/usr/local/bin/node]
#18 1221.5  2: 0x969880 node::FatalError(char const*, char const*) [/usr/local/bin/node]
#18 1221.5  3: 0xb74138 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
#18 1221.5  4: 0xb742c4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
#18 1221.5  5: 0xd1c820 v8::internal::Heap::EnsureFromSpaceIsCommitted() [/usr/local/bin/node]
#18 1221.5  6: 0xd1d288  [/usr/local/bin/node]
#18 1221.5  7: 0xd2af4c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
#18 1221.5  8: 0xd2e41c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
#18 1221.5  9: 0xd00714 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
#18 1221.5 10: 0x101ba54 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
#18 1221.5 11: 0x137bb0c  [/usr/local/bin/node]
#18 1221.5 qemu: uncaught target signal 6 (Aborted) - core dumped
#18 1221.7 Aborted
#18 1221.8 npm ERR! code ELIFECYCLE
#18 1221.8 npm ERR! errno 134
#18 1221.8 npm ERR! vue-antd-admin@0.7.4 build: `vue-cli-service build`
#18 1221.8 npm ERR! Exit status 134
#18 1221.8 npm ERR!
#18 1221.8 npm ERR! Failed at the vue-antd-admin@0.7.4 build script.
#18 1221.8 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
#18 1222.0
#18 1222.0 npm ERR! A complete log of this run can be found in:
#18 1222.0 npm ERR!     /root/.npm/_logs/2023-02-16T06_26_23_271Z-debug.log
------
executor failed running [/bin/sh -c npm run build]: exit code: 134


经过查看发现NPM异常退出代码134,通过错误代码了解到应该是内存不足导致的。优先确认自己使用的这台物理机器内存,并未发现问题。应该是Docker本身子系统内存问题,经过查看确认允许内存为2G,这内存允许范围的确可能出现内存不足的问题。将内存设置为4GB后保存,再次构建项目,经过一段时间的等待,Docker镜像构建成功。

Docker构建VUE项目NPM构建134异常-第1张图片

Docker构建VUE项目NPM构建134异常-第2张图片



转载请注明:清风亦平凡 » Docker构建VUE项目NPM构建134异常

喜欢 (0)or分享 (0)
支付宝扫码打赏 支付宝扫码打赏 微信打赏 微信打赏
头像
发表我的评论
取消评论

CAPTCHA Image
Reload Image
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址