【问题标题】:Error while executing command: node --max_old_space_size=3072 node_modules/@vue/cli-service/bin/vue-cli-service.js build执行命令时出错:node --max_old_space_size=3072 node_modules/@vue/cli-service/bin/vue-cli-service.js build
【发布时间】:2020-06-21 11:07:53
【问题描述】:

我在 AWS codeBuild 中的一些项目,我遇到的问题是从昨天开始我在构建中遇到了这个错误

[Container] 2020/03/09 12:51:00 Running command node --max_old_space_size=3072 node_modules/@vue/cli-service/bin/vue-cli-service.js build --mode production

-  Building for production...
Killed

[Container] 2020/03/09 12:53:29 Command did not exit successfully node --max_old_space_size=3072 node_modules/@vue/cli-service/bin/vue-cli-service.js build --mode production exit status 137
[Container] 2020/03/09 12:53:29 Phase complete: BUILD State: FAILED
[Container] 2020/03/09 12:53:29 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: node --max_old_space_size=3072 node_modules/@vue/cli-service/bin/vue-cli-service.js build --mode production. Reason: exit status 137

我知道该项目可能正在尝试使用超过 3072Mb 的内存,但我不知道为什么,我有另一个项目有更多的页面和组件并且它没有抛出那个错误。

那么问题来了

我怎么知道有多少 ram 正在使用该节点在本地构建 vue 项目? 如何优化构建过程? 节点模块与此有关吗?这个有错误的项目比另一个有更多的包。

【问题讨论】:

    标签: node.js amazon-web-services vue.js vuejs2 aws-codebuild


    【解决方案1】:

    以下几个网页表明这可能是 RAM 问题。

    错误消息中的 node 命令具有 --- max-old-space-size 标志,它将内存限制设置为 3gb,而不是默认的 512mb。

    这个 3gb 值应该与构建项目的计算类型相匹配:

    您可能使用具有 3gb 的“build.general1.small”,但节点可能无法分配所有这些。

    那么你可以尝试使用更少的内存读取的命令,例如

    $ node --max_old_space_size=2560 node_modules/@vue/cli-service/bin/vue-cli-service.js build --mode production
    

    或者您可以尝试升级计算类型,但这可能会导致价格上涨。

    【讨论】:

      猜你喜欢
      • 2021-10-19
      • 1970-01-01
      • 2019-02-07
      • 1970-01-01
      • 2020-01-25
      • 2021-12-29
      • 2019-06-12
      • 2021-06-20
      • 2021-02-16
      相关资源
      最近更新 更多