npm Github操作-已达到堆限制分配失败

3bygqnnd  于 2022-11-14  发布在  Git
关注(0)|答案(1)|浏览(173)

Github Action在上次“运行:npm运行构建”

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
Error: Process completed with exit code 1.

我的工作流文件

name: Node.js CI

on:
  push:
    branches: ['master']

jobs:
  build:
    runs-on: self-hosted

    strategy:
      matrix:
        node-version: [16.x]
        # See supported Node.js release schedule at https://nodejs.org/en/about/releases/

    steps:
      - uses: actions/checkout@v3
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
          cache: 'npm'
      - run: npm i
      - run: npm i
        working-directory: client
      - run: npm run build --if-present
        working-directory: client

我认为这是解决办法

env:
   NODE_OPTIONS: "--max-old-space-size=4096"

但它还没有工作,我不确定是否需要在env之前添加“-”以及它的确切位置...我在“run:npm运行build --如果存在工作目录:客户端”,但不起作用。

ykejflvf

ykejflvf1#

根据对类似问题的回应:
run

jobs:
  make-love:
    steps:
      - name: "Just do it"
        run: |
        export NODE_OPTIONS="--max_old_space_size=4096"
        npm start

env

jobs:
  make-love:
    steps:
      - name: "Nothing is impossible"
        env:
          NODE_OPTIONS: "--max_old_space_size=4096"
        run: npm start

相关问题