0

I am having an issue whereare I get the following error when one of my pipelines run on Azure.

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

This is a pipeline that is run on pull request. It also occurs on the npm run test:ci stage of the build as shown here:

enter image description here

Here is the yml file for the pipeline. I have attempted to up the max_old_space_size on node installation as you can see on the first task but this hasn't helped.

# Node.js with React
# Build a Node.js project that uses React.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/javascript

pool:
  vmImage: ubuntu-latest

jobs:
  - job: Build
    condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
    steps:
      - task: NodeTool@0
        inputs:
          versionSpec: '14.x'
        displayName: 'Install Node.js'
        env:
          NODE_OPTIONS: --max_old_space_size=16384

      - task: npmAuthenticate@0
        inputs:
          workingFile: .npmrc
        displayName: 'Authenticate npm'

      - script: npm install
        displayName: 'npm install'        

      - script: npm run test:ci
        displayName: 'npm run test:ci'

      - script: npm run lint
        displayName: 'npm run lint'

      - script: npm run build
        displayName: 'npm run build'

Has anyone encountered anything similar? Thanks

James
  • 2,800
  • 7
  • 45
  • 81

1 Answers1

2

You can try adding a powershell task to set the environment variable before the install node task to check if it works:

- task: PowerShell@2
  displayName: build
  env:
    NODE_OPTIONS: --max_old_space_size=16384

For more information, you could refer to: JavaScript heap out of memory on Azure build

Ging Yuan-MSFT
  • 689
  • 2
  • 6